restrict tag names to a pattern?

Z

zmunkz

Does anyone know if an XSD can define tags that match a pattern? I
know I can setup restrictions on the values of a tag, but I want to
control the tag names themselves. For example, I would like this to
validate against my XSD (the child tags are required to start with
"var-" but can end in anything):

<some-parent>
<var-FOO>value</var-FOO>
<var-BAR>value</var-BAR>
</some-parent>

So this one would be no good:

<some-parent>
<FOO>value</FOO>
<va-BAR>value</va-BAR>
</some-parent>

There must be a way to do this, I just can't find it anywhere...
Thanks in advance for the help!
 
M

Martin Honnen

zmunkz said:
Does anyone know if an XSD can define tags that match a pattern? I
know I can setup restrictions on the values of a tag, but I want to
control the tag names themselves. For example, I would like this to
validate against my XSD (the child tags are required to start with
"var-" but can end in anything):

<some-parent>
<var-FOO>value</var-FOO>
<var-BAR>value</var-BAR>
</some-parent>

So this one would be no good:

<some-parent>
<FOO>value</FOO>
<va-BAR>value</va-BAR>
</some-parent>

There must be a way to do this, I just can't find it anywhere...


No, that is not possible with the W3C XML schema language.
 
M

Martin Honnen

zmunkz said:
Does anyone know if an XSD can define tags that match a pattern? I
know I can setup restrictions on the values of a tag, but I want to
control the tag names themselves. For example, I would like this to
validate against my XSD (the child tags are required to start with
"var-" but can end in anything):

<some-parent>
<var-FOO>value</var-FOO>
<var-BAR>value</var-BAR>
</some-parent>

So this one would be no good:

<some-parent>
<FOO>value</FOO>
<va-BAR>value</va-BAR>
</some-parent>

There must be a way to do this, I just can't find it anywhere...


No, that is not possible with the W3C XML schema language.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top