Re: [xml] xmlSchemaValidateDoc

   I have few queries:
   1. Do we need to have the elements in the same order in 
xml as xsd ?

Yes, as long as you define <xs:sequence> in your XSD the elements have
to be in the same order in the XML as in your XSD.

   2. As i am also using xmlAddChild to add new elements 
(which gets added at the end) and hence my validation failed. 

      is there any options to validate  xml  (which has 
elements not in same order as defined in xsd ) against xsd in 
out-of-order way.

No. Redefine your XSD or your code that creates your XML.

   3.Otherwise ,what options do i have so that xmlAddChild 
adds the element at the right place instead at the end. 

Have a look at xmlAddNextSibling and xmlAddPrevSibling. These functions
add a node next or previous a given other node as sibling.

    Please point if i am totally in wrong direction .

If you want to add the elements in no specific order, have a look at
<xs:all> which you can use instead of <xs:sequence> in you XSD. But be
careful <xs:all> cannot be used as a replacement of <xs:sequence>, there
are some restrictions. The XSD book/page/reference (I use "XML Schema"
from O'Reilly) of your choice describes it in detail...

Best regards
Andreas Tscharner                          andreas tscharner metromec ch
And the beast shall come forth surrounded by a roiling cloud of
vengeance. The house of the unbelievers shall be razed and they shall be
scorched to the earth. Their tags shall blink until the end of days.
                                            -- The Book of Mozilla 12:10

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]