none
Xsd validation RRS feed

  • Question

  • Hi,

            I've a simple xml with one element "Book" which have 3 attributes author, edition, price. I need to create an xsd for this based on condition that,
    if edition is "free", the price attribute need not have value/price attribute need not be required, and if edition is "paid", the price attribute should be a decimal value.
     
            Below mentioned is the sample xml file. Currently I've used .Net IDE to create xsd and used custom datatype to define this. I used xs:choice to do this, but  was not working as it was not supporting attributes.

    <?xml version="1.0" encoding="utf-8"?>
    <
    Library xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="sample.xsd">

    <Book name="Sample book 1" author="Sample author 1" edition="free" price=""></Book>

    <Book name="Sample book 2" author="Sample author 2" edition="paid" price="100.0"></Book>

    </Library>

    Thanks in advance...


    .net
    Wednesday, November 19, 2008 9:46 AM

All replies