You're not off base. In your example, the union operator would force uniqueness of the name attribute across both types of elements. That's a bug.
The fix is in CVS. I have attached the diff for your reference. Khaled [EMAIL PROTECTED] wrote: > Khaled Noaman wrote: > > > > There is a small fix that you need to apply to XUtil.cpp. > > In XUtil::getNextSiblingElementNS and XUtil::getFirstChildElementNS replace > > 'getNodeName()' with 'getLocalName()'. > > > > Would you please apply that fix, and test the parser again? If the parser is > > still ignoring the identity constraints, would you please post an example to > > the mailing list? > > Yes, this helps. Thanks. > > Another question: Does the union operator in a selector work? Take the > following uniqueness constraint as an example: > > <xs:unique name="element_key"> > <xs:selector xpath="element_one|element_two" /> > <xs:field xpath="@name" /> > </xs:unique> > > My expectation was that this should enforce uniquenes of the name > attribute across both types of elements. Instead, it seems that the > element after the '|' is completely ignored, i.e. this behaves as if I had > specified this: > > <xs:unique name="element_key"> > <xs:selector xpath="element_one" /> > <xs:field xpath="@name" /> > </xs:unique> > > Am I totally off-base here? > > Joachim > > -- > work: [EMAIL PROTECTED] (http://www.netacquire.com) > private: [EMAIL PROTECTED] (http://www.kraut.ca) > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
Index: TraverseSchema.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/validators/schema/TraverseSchema.cpp,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- TraverseSchema.cpp 2001/12/03 21:18:32 1.68 +++ TraverseSchema.cpp 2001/12/06 17:03:36 1.69 @@ -55,7 +55,7 @@ */ /* - * $Id: TraverseSchema.cpp,v 1.68 2001/12/03 21:18:32 knoaman Exp $ + * $Id: TraverseSchema.cpp,v 1.69 2001/12/06 17:03:36 knoaman Exp $ */ // --------------------------------------------------------------------------- @@ -3906,21 +3906,36 @@ // Get xpath attribute // ------------------------------------------------------------------ const XMLCh* xpathExpr = getElementAttValue(elem, SchemaSymbols::fgATT_XPATH, true); + unsigned int xpathLen = XMLString::stringLen(xpathExpr); - if (!xpathExpr || !XMLString::stringLen(xpathExpr)) { + if (!xpathExpr || !xpathLen) { reportSchemaError(XMLUni::fgXMLErrDomain, XMLErrs::IC_XPathExprMissing); return false; } - if (XMLString::startsWith(xpathExpr, fgForwardSlash) - || XMLString::startsWith(xpathExpr, fgDot)) { - fBuffer.set(xpathExpr); - } - else { - fBuffer.set(fgDotForwardSlash); - fBuffer.append(xpathExpr); + fBuffer.reset(); + + unsigned int startIndex = 0; + + while (startIndex < xpathLen) { + + if (!XMLString::startsWith(xpathExpr + startIndex, fgForwardSlash) + && !XMLString::startsWith(xpathExpr + startIndex, fgDot)) { + fBuffer.append(fgDotForwardSlash); + } + + int chOffset = XMLString::indexOf(xpathExpr, chPipe, startIndex); + + if (chOffset == -1) + break; + + fBuffer.append(xpathExpr + startIndex, chOffset + 1); + startIndex = chOffset + 1; } + + if (startIndex < xpathLen) + fBuffer.append(xpathExpr + startIndex); // ------------------------------------------------------------------ // Parse xpath expression 1.3 +8 -0 xml-xerces/c/src/validators/schema/identity/ValueStore.cpp Index: ValueStore.cpp =================================================================== RCS file: /home/cvs/xml-xerces/c/src/validators/schema/identity/ValueStore.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ValueStore.cpp 2001/11/20 20:32:52 1.2 +++ ValueStore.cpp 2001/12/06 17:03:37 1.3 @@ -56,6 +56,9 @@ /* * $Log: ValueStore.cpp,v $ + * Revision 1.3 2001/12/06 17:03:37 knoaman + * Identity Constraint: fix for xpath expressions containing union operator(s). + * * Revision 1.2 2001/11/20 20:32:52 knoaman * Bypass validating element's simple content if it's empty and element is nillable. * @@ -154,6 +157,11 @@ FieldValueMap* valueMap = other->fValueTuples->elementAt(i); if (!contains(valueMap)) { + + if (!fValueTuples) { + fValueTuples = new RefVectorOf<FieldValueMap>(4); + } + fValueTuples->addElement(new FieldValueMap(*valueMap)); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]