Another disagreement with XML Spy
Having trouble installing Oxygen? Got a bug to report? Post it all here.
Another disagreement with XML Spy
Hey, George !! I have another one:
I am trying to define a schema for Latitide/Longitude such that it can be expressed as degrees, minutes, and seconds.
Normally, the restrictions would be (for latitude) degrees > 90, minutes > 60, and seconds > 60
The problem is that 90d0m0s is also a valid latitude.
My colleague who swears by XML Spy (while I just swear at it) came up with this:
Oxygen says it is invalid.
Is there a valid way to to this ?
I am trying to define a schema for Latitide/Longitude such that it can be expressed as degrees, minutes, and seconds.
Normally, the restrictions would be (for latitude) degrees > 90, minutes > 60, and seconds > 60
The problem is that 90d0m0s is also a valid latitude.
My colleague who swears by XML Spy (while I just swear at it) came up with this:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by Dan White (NGIT-DMS) -->
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="LatitudeType">
<xs:choice>
<xs:sequence>
<xs:element name="deg">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:maxInclusive value="90"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="min" type="xs:decimal" fixed="0"/>
<xs:element name="sec" type="xs:decimal" fixed="0"/>
<xs:element name="dir">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="N"/>
<xs:enumeration value="n"/>
<xs:enumeration value="S"/>
<xs:enumeration value="s"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:sequence>
<xs:element name="deg">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:maxExclusive value="90"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="min">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:maxExclusive value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="sec" fixed="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
<xs:maxExclusive value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="dir">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="N"/>
<xs:enumeration value="n"/>
<xs:enumeration value="S"/>
<xs:enumeration value="s"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:choice>
</xs:complexType>
</xs:schema>
Code: Select all
E cos-element-consistent: Error for type 'LatitudeType'. Multiple elements with name 'deg', with different types, appear in the model group.
E cos-nonambig: "":deg and "":deg (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles.
Hi Dan,
As you already found out on the xml-dev list [1] oXygen is right in reporting these errors and more, you cannot represent these kind of constraints in XML Schema.
Oxygen has support also for Relax NG [2] and you can do this easily in a Relax NG schema. In compact syntax that will look like:
and in xml syntax it is:
[1] http://lists.xml.org/archives/xml-dev/2 ... 00251.html
[2] http://www.relaxng.org/
Best Regards,
George
As you already found out on the xml-dev list [1] oXygen is right in reporting these errors and more, you cannot represent these kind of constraints in XML Schema.
Oxygen has support also for Relax NG [2] and you can do this easily in a Relax NG schema. In compact syntax that will look like:
Code: Select all
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
start = element latitude { LatitudeType }
LatitudeType =
(element deg { "90" },
element min { "0" },
element sec { "0" },
dir)
| (element deg {
xsd:decimal { minInclusive = "0" maxExclusive = "90" }
},
element min {
xsd:decimal { minInclusive = "0" maxExclusive = "60" }
},
element sec {
xsd:decimal { minInclusive = "0" maxExclusive = "60" }
},
dir)
dir = element dir { "s" | "S" | "n" | "N" }
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<element name="latitude">
<ref name="LatitudeType"/>
</element>
</start>
<define name="LatitudeType">
<choice>
<group>
<element name="deg"><value>90</value></element>
<element name="min"><value>0</value></element>
<element name="sec"><value>0</value></element>
<ref name="dir"/>
</group>
<group>
<element name="deg">
<data type="decimal">
<param name="minInclusive">0</param>
<param name="maxExclusive">90</param>
</data>
</element>
<element name="min">
<data type="decimal">
<param name="minInclusive">0</param>
<param name="maxExclusive">60</param>
</data>
</element>
<element name="sec">
<data type="decimal">
<param name="minInclusive">0</param>
<param name="maxExclusive">60</param>
</data>
</element>
<ref name="dir"/>
</group>
</choice>
</define>
<define name="dir">
<element name="dir">
<choice>
<value>s</value>
<value>S</value>
<value>n</value>
<value>N</value>
</choice>
</element>
</define>
</grammar>
[2] http://www.relaxng.org/
Best Regards,
George
Thanks for the reply, George.
I am just getting comfortable messing with schema, I am not sure I want to complicate matters by adding new things to it.
Besides, as I mentioned in my other thread, I am planning to use the Xerces C++ library to utilize these schemas for message exchange. Unless Xerces supports this RelaxNG, I will just use my fallback of typing my latitudes and longitudes as single, decimal numbers that I can easily restrict as opposed to triplets of numbers that are proving difficult to validate.
I will look at RelaxNG for future considerations.
Again, thanks for your help.
I am just getting comfortable messing with schema, I am not sure I want to complicate matters by adding new things to it.
Besides, as I mentioned in my other thread, I am planning to use the Xerces C++ library to utilize these schemas for message exchange. Unless Xerces supports this RelaxNG, I will just use my fallback of typing my latitudes and longitudes as single, decimal numbers that I can easily restrict as opposed to triplets of numbers that are proving difficult to validate.
I will look at RelaxNG for future considerations.
Again, thanks for your help.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service