XML Schema Question

C

Colin Goudie

How would you generate a schema for an complex type that needs atrributes
and match a pattern
i.e.
XML
<BaseIpAddress name="Base I.P. Address">203.0.171.191</BaseIpAddress>

the ip number in the tags needs to be correctly formatted
with minLength=7, maxLength=15, and pattern "

Currently I have this

<xs:element name="BaseIpAddress">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"
fixed="Base I.P. Address" />
<xs:attribute name="value" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="7" />
<xs:maxLength value="15" />
<xs:pattern
value="\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="units" type="xs:string" use="optional"
fixed="I.P. Ver4 Address" />
</xs:complexType>
</xs:element>

But that equates to
<BaseIpAddress name="Base I.P.Address" value="0.0.0.0" units="I.P. Ver4
Address"/>

I'd like this not to be an empty tag
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top