Is it possible to define XML schemas with node names given using regular expressions?

I know this is probably a question against XML philosophy, but it is still possible to define schemas for XML like this:

<Root>
  <arbitrary-name-of-node>
   <Name></Name>
   <Position></Position>
   <!-- ... -->
  </arbitrary-name-of-node>

  <arbitrary-name-of-node>
   <Name></Name> 
   <Position></Position>
   <!-- ... -->
  </arbitrary-name-of-node>
</Root>

      

where an arbitrary w630-name matches the regular expression [a-zA-Z0-9]?

Thanks for the answer!

+2


a source to share


2 answers




+1


a source


I do not think that's possible.

The way I see it, you have two options.

1. Create a schema like this and add each "arbitrary w630-name>" under the root type.



<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:all>
        <xs:element name="arbitrary-name-of-node1" type="itemType" />
        <xs:element name="arbitrary-name-of-node2" type="itemType" />
        <xs:element name="arbitrary-name-of-node3" type="itemType" />
      </xs:all>
    </xs:complexType>
  </xs:element>
  <xs:complexType name="itemType">
    <xs:sequence>
      <xs:element name="Name" />
      <xs:element name="Position" />
      <!--...-->
    </xs:sequence>
  </xs:complexType>
</xs:schema>

      

2. Create a schema just for the content inside "arbitrary-from-w630>" and check each node.

+1


a source







All Articles