none
How to restrict XSD tag value to be ordered like 1,2,3…to check XML

    Question

  • Hi,

    How to restrict XSD tag value to be ordered like 1,2,3…to check XML.

    Like...

    <person>

            <jobid>1</jobid>

            <jobid>2</jobid>

            <jobid>3</jobid>

    </person>

    I want job ID to be in numerical order. How can I achive this in XSD.

    Thanks

    Sreenath


    Cheers Sreenath G V


    • Edited by Sreenath GV Monday, November 18, 2013 11:51 AM
    Monday, November 18, 2013 11:21 AM

Answers

  • You cannot validate the order of job IDs using only XML Schema, because it doesn't provide any arithmetic operations or less-than comparisons with things other than constants, and the restricted XPath subset doesn't include such operations either.

    Instead, consider using XSLT or Schematron.  They support enough XPath to do this easily.

    Or use your favourite programming language with an XML reader library.  It won't even be necessary to keep the whole document in memory.


    • Edited by ranta Tuesday, November 19, 2013 5:03 PM disambiguate
    • Marked as answer by Sreenath GV Wednesday, November 20, 2013 6:12 AM
    Tuesday, November 19, 2013 5:03 PM