Unique Doesn't Work
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Thu Jan 16, 2014 3:31 pm
Unique Doesn't Work
Hi All,
I have the following XML file (I deleted from this example the reference to the XML schema to keep it clean):
This is my XML schema:
I would expect that the XML file wouldn't pass the validation because "10" appears twice as the value of <command_name>. But Oxygen keeps saying that the file is OK. If I intentionally try to do other invalid things (just to check that the schema is working at all), like entering string values into <command_name>, it does say that I entered an invalid value.
Am I doing anything wrong?
Thanks!
Alex
I have the following XML file (I deleted from this example the reference to the XML schema to keep it clean):
Code: Select all
<command_group>
<command>
<command_name>10</command_name>
<command_description>My command description</command_description>
</command>
<command>
<command_name>12</command_name>
<command_description>My another command description</command_description>
</command>
<command>
<command_name>10</command_name>
<command_description>ewewe</command_description>
</command>
</command_group>
This is my XML schema:
Code: Select all
<xs:element name="command_group">
<xs:complexType>
<xs:sequence>
<xs:element name="command" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="command_name" type="xs:integer" />
<xs:element name="command_description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="uniqueCommand">
<xs:selector xpath="command" />
<xs:field xpath="command_name" />
</xs:unique>
</xs:element>
Am I doing anything wrong?
Thanks!
Alex
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Unique Doesn't Work
Hi,
Using just the code snippets that you provided, it doesn't pass validation. Both Xerces and Saxon-EE report the problem:
Is there a target namespace for the schema?
If that's the case, note that the XPath expressions used in the @xpath attributes need the appropriate namespace to be specified. Have a look at the "personal.xsd" sample file from the Oxygen samples (Oxygen/samples/personal.xsd).
Regards,
Adrian
Using just the code snippets that you provided, it doesn't pass validation. Both Xerces and Saxon-EE report the problem:
Code: Select all
E [Xerces] cvc-identity-constraint.4.1: Duplicate unique value [10] declared for identity constraint "uniqueCommand" of element "command_group".
Code: Select all
E [Saxon-EE 9.5.1.2] Non-unique value found for constraint uniqueCommand: 10
If that's the case, note that the XPath expressions used in the @xpath attributes need the appropriate namespace to be specified. Have a look at the "personal.xsd" sample file from the Oxygen samples (Oxygen/samples/personal.xsd).
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
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