Click here to Skip to main content
14,830,805 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: I need an ebay program Pin
Ashfield14-Jan-10 1:26
MemberAshfield14-Jan-10 1:26 
JokeRe: I need an ebay program [modified] Pin
The Man from U.N.C.L.E.14-Jan-10 6:43
MemberThe Man from U.N.C.L.E.14-Jan-10 6:43 
QuestionUsing unparsed entities in schemas Pin
rusgregor12-Jan-10 21:46
Memberrusgregor12-Jan-10 21:46 
AnswerRe: Using unparsed entities in schemas Pin
Stuart Dootson13-Jan-10 0:26
professionalStuart Dootson13-Jan-10 0:26 
GeneralRe: Using unparsed entities in schemas Pin
rusgregor13-Jan-10 4:18
Memberrusgregor13-Jan-10 4:18 
GeneralRe: Using unparsed entities in schemas Pin
Stuart Dootson13-Jan-10 4:25
professionalStuart Dootson13-Jan-10 4:25 
GeneralRe: Using unparsed entities in schemas Pin
rusgregor14-Jan-10 3:23
Memberrusgregor14-Jan-10 3:23 
GeneralRe: Using unparsed entities in schemas Pin
Stuart Dootson14-Jan-10 4:44
professionalStuart Dootson14-Jan-10 4:44 
I used the .NET XML parser.

Here's my little C# program:

using System;
using System.Xml;
using System.Xml.Schema;
namespace a
{
   class Program
   {
      static public void vvv(Object sender, ValidationEventArgs e)
      {
         Console.WriteLine(e.Message);
         throw new XmlSchemaValidationException();
      }

      static void Main(string[] args)
      {
         try
         {
            XmlDocument xmldoc = new XmlDocument();
            xmldoc.PreserveWhitespace = false;

            xmldoc.Load("Changes.xml");
            Console.WriteLine(xmldoc.DocumentElement.Name);
            Console.WriteLine("The document has {0} entities", xmldoc.DocumentType.Entities.Count);

            XmlSchemaSet schema = new XmlSchemaSet();
            schema.Add("", "change-history.xsd");
            xmldoc.Schemas = schema;
            xmldoc.Validate(vvv);
            Console.WriteLine("Document validated!");
         }
         catch (XmlSchemaValidationException)
         {
            Console.WriteLine("Document didn't validate!");
         }
      }
   }
}


Here's my schema (called change-history.xsd)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified">
  <xs:element name="change-history">
    <xs:annotation>
      <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="items">
          <xs:complexType>
            <xs:sequence maxOccurs="unbounded">
              <xs:element name="item">
                <xs:complexType>
                  <xs:sequence maxOccurs="unbounded">
                    <xs:element name="version">
                      <xs:complexType>
                        <xs:sequence maxOccurs="unbounded">
                          <xs:element name="change">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="xs:string">
                                  <xs:attribute name="reason" type="xs:string" use="optional"/>
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="number" type="xs:string" use="required"/>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="name" type="xs:string" use="required"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="product" type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>
</xs:schema>


And here's my sample XML file
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE change-history [
<!ENTITY eacute "&#xE9;">
]>
<change-history product="Sample" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="change-history.xsd">
   <items>
      <item name="Sample.exe">
         <version number="2.21.0">
            <change reason="issue 11">Added license to executable.</change>
            <change>&eacute;Fixed bug in executable.</change>
         </version>
      </item>
   </items>
</change-history>


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

MVP for 2010 - who'd'a thunk it!

GeneralRe: Using unparsed entities in schemas Pin
rusgregor14-Jan-10 21:24
Memberrusgregor14-Jan-10 21:24 
GeneralRe: Using unparsed entities in schemas Pin
Stuart Dootson14-Jan-10 22:00
professionalStuart Dootson14-Jan-10 22:00 
GeneralRe: Using unparsed entities in schemas Pin
rusgregor18-Jan-10 2:09
Memberrusgregor18-Jan-10 2:09 
QuestionXQuery Pin
Lutosław9-Jan-10 23:40
MemberLutosław9-Jan-10 23:40 
AnswerRe: XQuery Pin
Stuart Dootson12-Jan-10 3:07
professionalStuart Dootson12-Jan-10 3:07 
GeneralRe: XQuery Pin
Lutosław12-Jan-10 4:02
MemberLutosław12-Jan-10 4:02 
AnswerRe: XQuery Pin
Lutosław12-Jan-10 4:01
MemberLutosław12-Jan-10 4:01 
QuestionXML opening with IE Pin
Aljaz1117-Jan-10 4:07
MemberAljaz1117-Jan-10 4:07 
AnswerRe: XML opening with IE Pin
vivasaayi7-Jan-10 18:20
Membervivasaayi7-Jan-10 18:20 
QuestionXML With C# Pin
jojoba20105-Jan-10 22:23
Memberjojoba20105-Jan-10 22:23 
AnswerRe: XML With C# Pin
vivasaayi7-Jan-10 18:45
Membervivasaayi7-Jan-10 18:45 
QuestionHow can I generate multiple classes from xsd’s with common includes? Pin
sri_00994-Jan-10 2:46
Membersri_00994-Jan-10 2:46 
QuestionGenerate Dynamic controls using XSLT Pin
getaccessyr3-Jan-10 22:33
Membergetaccessyr3-Jan-10 22:33 
AnswerRe: Generate Dynamic controls using XSLT Pin
Not Active4-Jan-10 1:19
mentorNot Active4-Jan-10 1:19 
QuestionGetting zero elements with xmldocument.selectnodes Pin
Haim Nachum2-Jan-10 10:55
MemberHaim Nachum2-Jan-10 10:55 
AnswerRe: Getting zero elements with xmldocument.selectnodes Pin
Dexter Legaspi20-Jan-10 16:13
MemberDexter Legaspi20-Jan-10 16:13 
QuestionHelp with xml within dll file Pin
LeeWhit28-Dec-09 19:36
MemberLeeWhit28-Dec-09 19:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.