Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

XSD files

  • 03-02-2012 1:19am
    #1
    Registered Users, Registered Users 2 Posts: 9,390 ✭✭✭


    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,689 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 Posts: 9,390 ✭✭✭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