Jump to content

XML, DTD, xml:lang - argaaaaah!


Sery
 Share

Recommended Posts

Hello! I´m almost at my breaking point, please help, I´m going bald! :D I´ve done a simple wordlist (school project) and it is in three different languages.So, I´ve added the atribte xml:lang but I cannot get it to validate! Just that bit.Tried a few different ways to write it in the DTD and XSD, but nope. This is what it looks like in the XML: <wordlist_words xml:lang="fi"> I need it to work in a external DTD, an INTERNAL DTD, and a schema. Thanx in advance! :)

Link to comment
Share on other sites

DTD isn't aware of XML features like "xml:lang" or "xml:space", and "xml:id". XML Schema should be all right though.Can you give a reduced XML sample and the XML Schema you have?

Link to comment
Share on other sites

I figured it out for the DTD, so that is working now. :)The XML: <?xml version="1.0" encoding="iso-8859-1" standalone="no"?><?xml-stylesheet type="text/css" href="css.css"?><wordlist xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="wordlist_english_xsd.xsd"><information xml:lang="se"> <title>Engelsk ordlista</title> <author>XXX</author> <year>2012</year> </information> <wordlist_words xml:lang="en"> And then, the schema: (where I haven´t any code for the xml:lang, it just screwed everything up.) <?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="wordlist"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="information"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string" minOccurs="0"/> <xs:element name="author" type="xs:string" minOccurs="0"/> <xs:element name="year" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="wordlist_words"> Also, when I´m already here.. The namespace is confusing to me. What should I have? Thanx! :)

Link to comment
Share on other sites

Your XML should have whatever namespace you associate for the XSD. Since you have

xsi:noNamespaceSchemaLocation="wordlist_english_xsd.xsd"

You should have no namespace in the XML. In other words, remove

xmlns="http://www.w3schools.com"

Your XML and XSD samples are incomplete, so if the above change doesn't fix it, you'll have to reveal more - an XML and XSD that include all distinct elements you're going to have, at the minimum required times (i.e. no need to dump the whole word list, just one entry in the list containing all features).

Link to comment
Share on other sites

That was easy enough. It was a whole lot of "eh, what?" when I read about namespaces. Thank you! :) Here are the complete XML and XSD - enjoy! ;D XML <?xml version="1.0" encoding="iso-8859-1" standalone="no"?><?xml-stylesheet type="text/css" href="css.css"?><wordlist xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="wordlist_english_xsd.xsd"><information> <title>Engelsk ordlista</title> <author>Kristin, Mittuniversitetet, ITM</author> <year>2012</year> </information> <wordlist_words> <word>January</word> <word>February</word> <word>Mars</word> <word>April</word> <word>May</word> <word>June</word> <word>July</word> <word>August</word> <word>September</word> <word>October</word> <word>November</word> <word>December</word> </wordlist_words></wordlist> XSD: <?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="wordlist"> <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element name="information"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string" minOccurs="0"/> <xs:element name="author" type="xs:string" minOccurs="0"/> <xs:element name="year" type="xs:string" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="wordlist_words"> <xs:complexType> <xs:sequence> <xs:element name="word" nillable="true" minOccurs="0" maxOccurs="unbounded"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:choice> </xs:complexType> </xs:element></xs:schema>

Link to comment
Share on other sites

If you can now successfully validate it, I don't need it :P . Can you? At a quick glance, I can't see anything wrong, but if this fails validation, the error messages will be useful in pointing out the problem.

Link to comment
Share on other sites

Maybe if you remove the 'standalone="no"'. This attribute is supposed to instruct the parser that it must load the DTD (if provided) for purposes other than validation, but since you have no DTD, perhaps that makes xmllint think something is not right here.

Link to comment
Share on other sites

Hello again! Nope, my teacher went all "no-no-no" on me, so I did a new XSD. But, I clearly have my head under my arm and it won´t validate.Will you please help me? :( Im at my end here, so tired and fed up. Im no good at syntax - at all.

Link to comment
Share on other sites

I've tried it with all validators I have, and they all validate it.If your teacher is saying "no", he might mean that your schema is not according to the specification of the XML language.He should've provided you with some "human readable" description (a.k.a. "a specification") of what the XML is allowed to contain, like "'wordlist_words' element, with one or more 'words' element in it"... your XML Schema is supposed to reflect that description, whatever it might've been.I can't help at all without knowing the specification.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...