[ http://issues.apache.org/jira/browse/XERCESC-1516?page=comments#action_12332107 ]
David Bertoni commented on XERCESC-1516: ---------------------------------------- I don't believe this is a bug. In XPath 1.0, the default namespace is not used when an XPath expression contains a node test without a prefix: http://www.w3.org/TR/xpath#node-tests "A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done for element type names in start and end-tags except that the default namespace declared with xmlns is not used: if the QName does not have a prefix, then the namespace URI is null (this is the same way attribute names are expanded). It is an error if the QName has a prefix for which there is no namespace declaration in the expression context." > identity constraint volation not caught when xpath contains default namespace > ----------------------------------------------------------------------------- > > Key: XERCESC-1516 > URL: http://issues.apache.org/jira/browse/XERCESC-1516 > Project: Xerces-C++ > Type: Bug > Components: Validating Parser (Schema) (Xerces 1.5 or up only) > Versions: 2.6.0 > Environment: Windows XP > Reporter: Andrew Fang > > The following schema contains an identity constraint on the uniqueness of > ISBN number. However, no error is reported when duplicated entries for ISBN > exist. The problem seem to be that XPath parser does not parse default > namespace correctly. If a prefix is added (xmlns:x="....") and use the prefix > in xpath expression (e.g. <xsd:selector xpath="x:Book"/> ...), the violation > is found. > The following is a possible fix for the problem: > in XercesXpath.cpp ln 510 and 585, change > if (scopeContext && !aToken == -1) { > prefix = stringPool->getValueForId(aToken); > uri = scopeContext->getNamespaceForPrefix(prefix); > } > to > if (scopeContext) { > if(aToken == -1) { // no prefix, must be default namespace > prefix = XMLUni::fgZeroLenString; > } else { > prefix = stringPool->getValueForId(aToken); > } > uri = scopeContext->getNamespaceForPrefix(prefix); > } > ------- Schema --------------- > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > targetNamespace="http://www.publishing.org" > xmlns="http://www.publishing.org" > elementFormDefault="qualified"> > <xsd:element name="BookCatalogue"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="Book" minOccurs="1" > maxOccurs="unbounded"> > <xsd:complexType> > <xsd:sequence> > <xsd:element > name="Title" type="xsd:string" minOccurs="1" maxOccurs="1"/> > <xsd:element > name="Author" type="xsd:string" minOccurs="1" maxOccurs="1"/> > <xsd:element > name="ISBN" type="xsd:string" minOccurs="1" maxOccurs="1"/> > <xsd:element > name="Publisher" type="xsd:string" minOccurs="1" maxOccurs="1"/> > <xsd:element > name="Date" type="xsd:string" minOccurs="1" maxOccurs="1"/> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > </xsd:sequence> > </xsd:complexType> > <xsd:unique name="ISBNnumber"> > <xsd:selector xpath="Book"/> > <xsd:field xpath="ISBN"/> > </xsd:unique> > </xsd:element> > </xsd:schema> > --------- xml instance ----------- > <?xml version="1.0" encoding="UTF-8"?> > <BookCatalogue > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xmlns="http://www.publishing.org" > xsi:schemaLocation="http://www.publishing.org idc001.nogen.xsd"> > <Book> > <Title>My Life and Times</Title> > <Author>Paul McCartney</Author> > <ISBN>43892</ISBN> > <Publisher>McMillin Publishing</Publisher> > <Date>1998</Date> > </Book> > <Book> > <Title>My Life and Times</Title> > <Author>Paul McCartney</Author> > <ISBN>43892</ISBN> > <Publisher>McMillin Publishing</Publisher> > <Date>1998</Date> > </Book> > </BookCatalogue> -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
