Click here to Skip to main content
15,883,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have defined .xsd file by using complex types with xsd:sequence

So it means the xml which I generate need to follow the sequence defined in .xsd

Here problem is i can't modify the .xsd to do any changes. and i dont have control while XML generation.

what i have is an .xsd file and some .xml file (generated by some one). by using these two files, Can I reorder the xml nodes acording to schema? (C# or XSLT)

Please help on this

[code sample from OP's comment]
XML
<xsd:complextype name="PersonName_Type">
    <xsd:sequence>
      <xsd:element name="Surname" minoccurs="0" maxoccurs="1" type="dfac:C-40"></xsd:element>
      <xsd:element name="GivenName" minoccurs="0" maxoccurs="1" type="dfac:C-40"></xsd:element>
      <xsd:element name="OtherGivenName" minoccurs="0" maxoccurs="unbounded" type="dfac:C-40"></xsd:element>
      <xsd:element name="TitlePrefix" minoccurs="0" maxoccurs="1" type="dfac:C-255"></xsd:element>
      <xsd:element name="NameSuffix" minoccurs="0" maxoccurs="1" type="dfac:C-40"></xsd:element>"
      <xsd:element name="NickName" minoccurs="0" maxoccurs="1" type="dfac:C-40"></xsd:element>
      <xsd:element name="GenderCd" minoccurs="0" maxoccurs="1" type="dfenum:GenderCd_Type"></xsd:element>
      <xsd:element name="BirthDt" minoccurs="0" maxoccurs="1" type="dfac:Date"></xsd:element>
      <xsd:element name="MaritalStatusCd" minoccurs="0" maxoccurs="1" type="dfenum:MaritalStatus_Type"></xsd:element>
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:ID"></xsd:attribute>
  </xsd:complextype>
Posted
Updated 3-Jun-15 3:35am
v3
Comments
Kornfeld Eliyahu Peter 3-Jun-15 9:28am    
Do you mean to force certain order of XML elements using XSD?
KVPalem 3-Jun-15 9:33am    
Yes, we are forcing the xml to follow some order using XSD.
Sample XSD below
i am not able to post sample xsd here
Maciej Los 3-Jun-15 10:55am    
Assuming, you want to move some nodes up/down depending on xsd schema?
KVPalem 4-Jun-15 1:39am    
Yes,this is what we required.
Sergey Alexandrovich Kryukov 3-Jun-15 11:12am    
Why not? where below?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900