Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

XSD files

  • 03-02-2012 02:19AM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 9,400 ✭✭✭


    I'm working with a set of XML files in an app and I'd like to validate them against an XSD (which I have to prepare). The only problem is that the names in the tags aren't constant, the attributes are. Is there any way to do this in XSD?

    For example
    <protocol1 ID="1" Action="Action1">
    <Name ID="1" type="String">Mark</Name>
    <Age ID="2" type="Int">30</Name>
    </protocol1>

    The next XML file will look something similar but the tag names will differ. Basically I want to check that my XML looks like this

    <{any} ID/Int Action/string>
    <{any} ID/Int type/String /> <-- this is a sequence
    </{/any}

    Thanks!


Comments

  • Moderators, Society & Culture Moderators Posts: 9,688 Mod ✭✭✭✭stevenmu


    I don't think so. Can you reform your XML so that your tag name is actually an attribute? For e.g.

    <entity type="protocol1" ID="1" Action="Action1">
    <property type="Name" ID="1" type="String">Mark</property>
    <property type="Age" ID="2" type="Int">30</property>
    </entity>


  • Registered Users, Registered Users 2, Paid Member Posts: 9,400 ✭✭✭markpb


    I'd rather avoid changing the format of the file if I can help it. It's a pity that XSD can't do what I want, I guess I'll have to roll my own :) Thanks though!


Advertisement