Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml editor complaining if hex value is used in enumeration

Status
Not open for further replies.

chhajjer

Technical User
Mar 22, 2008
2
US
I am new to xml ..

I have a schema check problem when i have enumeration has hex value

<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:unsignedByte">
<xs:enumeration value="0x23"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>


Hoever if the enumeration is replaced with an equivalent decimal value the problem goes way..
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:unsignedByte">
<xs:enumeration value="35"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>

can some one what is the problem here why is the hex value not working
 
[1] If the attribute value is understood as some kind of hexadecimal by some application, you have no choice but to declare it as xs:hexBinary.
[tt]
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="[red]xs:hexBinary[/red]">
<xs:enumeration value="23"/>
<xs:enumeration value="a"/> <!-- added for illustration -->
</xs:restriction>
</xs:simpleType>
</xs:attribute>
[/tt]
[2] And the xml document could only appear as something like this. You see hexadecimal, a and A are both validated even in the schema it is enumerated as "a".
[tt]
<somename type="23">...</somename>
<somename type="A">...</somename>
<somename type="a">...</somename>
[/tt]
[3] That hexademical must be recognized by the xml-aware application itself through some datatype property and retrieved as nodetypedvalue, not controlled by the schema.
 
Further note

[1-rev] It is better to present xs:hexBinary data by even length of its number as the binary is grouped by octet, although in the case of demo in [1], it should be running just fine.
[tt]
<xs:attribute name="type" use="required">
<xs:simpleType>
<xs:restriction base="xs:hexBinary">
<xs:enumeration value="23"/>
<xs:enumeration value="[red]0[/red]a"/> <!-- added for illustration -->
</xs:restriction>
</xs:simpleType>
</xs:attribute>
[/tt]
 
Thanks for the input ..This has nothing to do with the application here. the editor complains of the schema being not valid. I believe it has to do with lexial space for enumeration but cant find anything sort of this in the w3c standard
 
I don't think xs:unsignedByte would recognize 0x26 kind of representation in the schema document; that's why I proposed what I posted. In xml document in general, you have character entities like &#x26;, but that is another kind of thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top