can i use a qualifed attribute in a xs:field element
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 2
- Joined: Mon Mar 28, 2022 11:56 pm
can i use a qualifed attribute in a xs:field element
Post by darbouka_dribel »
I want to have an XSD schema that has an identity-constraint to ensure values in "code" attributes can be used as a key identity. the code attribute belong to a namesapce (code attribute must be qualified).
When i try to validate the following document XML against the above xsd file, I get this error:
cvc-identity-constraint.4.2.1.a: Element "list" has no value for the key "personKey".
Code: Select all
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="test.org"
elementFormDefault="qualified" attributeFormDefault= 'qualified'
xmlns:p = 'test.org'>
<xs:element name="list">
<xs:complexType>
<xs:sequence>
<xs:element name="person" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="first" type="xs:string"/>
<xs:element name="last" type="xs:string"/>
</xs:sequence>
<xs:attribute name="code" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="personKey">
<xs:selector xpath="p:person"/>
<xs:field xpath="@code"/>
</xs:key>
</xs:element>
</xs:schema>
cvc-identity-constraint.4.2.1.a: Element "list" has no value for the key "personKey".
Code: Select all
<list xmlns="test.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="test.org test.xsd">
<person xmlns:p="test.org" p:code="code1">
<first>first0</first>
<last>last0</last>
</person>
<person xmlns:p="test.org" p:code="code2">
<first>first1</first>
<last>last1</last>
</person>
</list>
-
- Posts: 388
- Joined: Thu Jul 01, 2004 12:29 pm
Re: can i use a qualifed attribute in a xs:field element
Hello,
You need to add also the prefix for the @code attribute. I think that the key definition should be something like this:
Best Regards,
Octavian
You need to add also the prefix for the @code attribute. I think that the key definition should be something like this:
Code: Select all
<xs:key name="personKey">
<xs:selector xpath="p:person"/>
<xs:field xpath="@p:code"/>
</xs:key>
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Mon Mar 28, 2022 11:56 pm
Re: can i use a qualifed attribute in a xs:field element
Post by darbouka_dribel »
tavy wrote: ↑Tue Mar 29, 2022 9:31 am Hello,
You need to add also the prefix for the @code attribute. I think that the key definition should be something like this:thanks a lot, it works fine.Code: Select all
<xs:key name="personKey"> <xs:selector xpath="p:person"/> <xs:field xpath="@p:code"/> </xs:key>
Best Regards,
Octavian
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