You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Alberto Massari <am...@datadirect.com> on 2005/05/25 17:08:27 UTC
Re: [jira] Resolved: (XERCESC-1422) uniq constraint validation
broken?
Hi Alex,
At 11.08 23/05/2005 -0400, Alex Nelson wrote:
>Alberto,
>
>Thank you for your reply. Where would I find the documentation that
>you mentioned? I looked in xerces-c.pdf and didn't find anything
>relevant. I looked at http://www.w3.org/TR/xmlschema-1/#components in
>section 3.11.6 and found some possibly relevant stuff, but not the
>restrictions that you mention.
Yes, § 3.11.6 is the section that defines what is legal; in the "Schema
Component Constraint: Fields Value OK", point 2.2 it says "It must be an
XPath expression involving the child and/or attribute axes whose
abbreviated form is as given above".
> There is a link to what is legal for
>XPath which I followed to http://www.w3.org/TR/1999/REC-xpath-19991116
That is the spec for the full XPath: XMLSchema parsers will only understand
what is in the XMLSchema specs.
>The text there seems to imply that I can use (as you suggest)
>
> child::id
>
>but that doesn't give me the validation error that want. Again, I can only
>seem to generate the validation error with
>
> child::*
The XPath expression you are writing doesn't reach the id element, as it is
executed starting from the tags element; try writing "tag" in the selector,
and "id" in the field.
Alberto
>How would I generate the uniq constraint only on the id node?
>This is what I tried; shouldn't it give the validation failure?
>I tried both with and without parens: child::id and child::id().
>
>
><?xml version="1.0"?>
><xs:schema
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="TStreams"
> xmlns="TStreams"
> elementFormDefault="qualified">
>
> <xs:element name="tags">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="tag" type="TagType" maxOccurs="unbounded" />
> </xs:sequence>
> </xs:complexType>
>
> <xs:unique name="uniqueTag">
> <xs:selector xpath="child::id()" />
> <xs:field xpath="."/>
> </xs:unique>
> </xs:element>
>
>
> <xs:complexType name="TagType">
> <xs:all>
> <xs:element name="id" type="xs:int" />
> </xs:all>
> </xs:complexType>
>
>
></xs:schema>
>
>
>
>
>
>
>
>On Saturday 21 May 2005 4:43 am, you wrote:
> > [ http://issues.apache.org/jira/browse/XERCESC-1422?page=all ]
> >
> > Alberto Massari resolved XERCESC-1422:
> > --------------------------------------
> >
> > Resolution: Invalid
> >
> > Hi Alex,
> > the XPath expressions you can put in the identity constraint are limited
> > (see § 3.11.6 of the specs): only 'child' and 'attribute' axis, and no
> > special functions like node() (btw, you missed the parenthesis). So, the
> > only correct form is child::id (or just id)
> >
> > Alberto
> >
> > > uniq constraint validation broken?
> > > ----------------------------------
> > >
> > > Key: XERCESC-1422
> > > URL: http://issues.apache.org/jira/browse/XERCESC-1422
> > > Project: Xerces-C++
> > > Type: Bug
> > > Components: Validating Parser (Schema) (Xerces 1.5 or up only)
> > > Versions: 2.6.0
> > > Environment: Downloaded xerces-C++ version 2.6.0, built from sources
> > > using g++ 3.4.1 on Mandrake Linux 10.1 Reporter: Alex Nelson
> > >
> > >
> > > I would like to validate that the id fields are unique in the list of
> > > tags. I got sort of close, but could only validate using child::*.
> > > I wanted to be more specific and make ids be unique.
> > > It seems to me that if child::* does tells me the xml is invalid, then
> > > certainly so should "child::node"
> > > Here is my xml file
> > > <?xml version="1.0"?>
> > > <tags
> > > xmlns="TStreams"
> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > > xsi:schemaLocation="TStreams file:///udir1/nelson/xml/ts3.xsd">
> > > <tag><id>3</id></tag>
> > > <tag><id>5</id></tag>
> > > <tag><id>3</id></tag>
> > > </tags>
> > > Here is my xsd file
> > > <?xml version="1.0"?>
> > > <xs:schema
> > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > targetNamespace="TStreams"
> > > xmlns="TStreams"
> > > elementFormDefault="qualified">
> > > <xs:element name="tags">
> > > <xs:complexType>
> > > <xs:sequence>
> > > <xs:element name="tag" type="TagType" maxOccurs="unbounded" />
> > > </xs:sequence>
> > > </xs:complexType>
> > > <xs:unique name="uniqueTag">
> > > <xs:selector xpath="child::*" /> <!-- this one
> > > works, but has no ref to 'id' --> <!-- <xs:selector xpath="child::node"/>
> > > --> <!-- this one doesn't but should if the previous does --> <!--
> > > <xs:selector xpath="descendant::id"/> --> <!-- this one gives
> > > "not supported" message --> <!-- <xs:selector
> > > xpath="descendant-or-self::id"/> --> <!-- this one is also "not
> > > supported" --> <xs:field xpath="."/>
> > > </xs:unique>
> > > </xs:element>
> > > <xs:complexType name="TagType">
> > > <xs:all>
> > > <xs:element name="id" type="xs:int" />
> > > </xs:all>
> > > </xs:complexType>
> > > </xs:schema>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
>For additional commands, e-mail: c-dev-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org