Hi Marv,
Some while back, Eddie Robertson posted a message where he diagnosed this
problem in another user's schema; perhaps a trip through the archives could
have dug out that note.
But the problem is non-obvious, so it's no doubt worth posting the cause
again: The default namespace isn't used in xpath expressions. So you're
<xsd:selector> is looking for a "B" element in the null namespace. But B
is in the schema's targetNamespace, tso no element is selected and no error
detected.
The fix is to bind an explicit prefix to the schema's targetNamespace and
use that in your selector's xpath attribute.
Hope that helps,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone: 905-413-3519, T/L 969-3519
E-mail: [EMAIL PROTECTED]
|---------+---------------------------->
| | [EMAIL PROTECTED]|
| | odak.com |
| | |
| | 08/26/2002 04:20 |
| | PM |
| | Please respond to|
| | xerces-j-user |
| | |
|---------+---------------------------->
>---------------------------------------------------------------------------------------------------------------------------------------------|
|
|
| To: [EMAIL PROTECTED]
|
| cc:
|
| Subject: xmlvalidator does not detect violations of uniqueness
|
|
|
|
|
>---------------------------------------------------------------------------------------------------------------------------------------------|
From: Marvin M. Goodgame
I am running an xmlvalidator application that is built on the Xerces-2.0.2
release using org.apache.xerces.parsers.SAXParser class for parsing. The
following features are set "true" on the parser:
http://xml.org/sax/features/validation
http://xml.org/sax/features/namespaces
http://apache.org/xml/features/validation/schema
http://apache.org/xml/features/validation/schema-full-checking
This xmlvalidator fails to report the violation of uniqueness for attribute
"b":
<A
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.example.com/A"
xsi:schemaLocation="http://www.example.com/A
file:/home/goodgame/tmp/A.xsd">
<B b="1"/>
<B b="2"/>
<B b="1"/>
</A>
as specified in the following schema:
<xsd:schema
targetNamespace="http://www.example.com/A"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.example.com/A">
<xsd:complexType name="AType">
<xsd:sequence>
<xsd:element ref="B" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="BType">
<xsd:attribute name="b" type="xsd:positiveInteger" use="required"/>
</xsd:complexType>
<xsd:element name="A" type="AType">
<xsd:unique name="dummy">
<xsd:selector xpath="B"/>
<xsd:field xpath="@b"/>
</xsd:unique>
</xsd:element>
<xsd:element name="B" type="BType"/>
</xsd:schema>
Can anyone tell me what I'm doing wrong?
Thanks,
Marv
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]