You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/02/20 08:47:06 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/validators/schema/identity Field.java Selector.java XPath.java
andyc 01/02/19 23:47:06
Modified: java/src/org/apache/xerces/validators/schema
TraverseSchema.java
java/src/org/apache/xerces/validators/schema/identity
Field.java Selector.java XPath.java
Log:
Updated XPath used for identity constraint selectors and
fields to not use targetNamespace for unqualified names
in xpath expressions. The code was originally written
that way due to a faulty example in the Schema CR primer
document.
Clarification from Martin Gudgin <ma...@develop.com>
Revision Changes Path
1.106 +6 -6 xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java
Index: TraverseSchema.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/TraverseSchema.java,v
retrieving revision 1.105
retrieving revision 1.106
diff -u -r1.105 -r1.106
--- TraverseSchema.java 2001/02/20 06:12:28 1.105
+++ TraverseSchema.java 2001/02/20 07:47:03 1.106
@@ -124,7 +124,7 @@
*
* @see org.apache.xerces.validators.common.Grammar
*
- * @version $Id: TraverseSchema.java,v 1.105 2001/02/20 06:12:28 andyc Exp $
+ * @version $Id: TraverseSchema.java,v 1.106 2001/02/20 07:47:03 andyc Exp $
*/
public class TraverseSchema implements
NamespacesScope.NamespacesHandler{
@@ -4370,7 +4370,7 @@
// implied assumption that the URI for unqualified
// steps is equal to the target namespace). -Ac
sxpath = new Selector.XPath(stext, fStringPool,
- fNamespacesScope, fTargetNSURI);
+ fNamespacesScope);
Selector selector = new Selector(sxpath, ic);
if (DEBUG_IDENTITY_CONSTRAINTS) {
System.out.println("<IC>: selector: "+selector);
@@ -4403,7 +4403,7 @@
// implied assumption that the URI for unqualified
// steps is equal to the target namespace). -Ac
Field.XPath fxpath = new Field.XPath(ftext, fStringPool,
- fNamespacesScope, fTargetNSURI);
+ fNamespacesScope);
// REVISIT: Get datatype validator. -Ac
DatatypeValidator validator = getDatatypeValidatorFor(parent, sxpath, fxpath);
if (DEBUG_IC_DATATYPES) {
@@ -4462,7 +4462,7 @@
}
if (index == -1) {
// REVISIT: Add message. -Ac
- reportGenericSchemaError("no such element "+fStringPool.toString(nodeTest.name.localpart));
+ reportGenericSchemaError("no such element \""+fStringPool.toString(nodeTest.name.rawname)+'"');
return null;
}
edeclIndex = index;
@@ -4498,7 +4498,7 @@
int adeclIndex = fSchemaGrammar.getAttributeDeclIndex(edeclIndex, nodeTest.name);
if (adeclIndex == -1) {
// REVISIT: Add message. -Ac
- reportGenericSchemaError("no such attribute "+fStringPool.toString(nodeTest.name.localpart));
+ reportGenericSchemaError("no such attribute \""+fStringPool.toString(nodeTest.name.rawname)+'"');
}
XMLAttributeDecl adecl = new XMLAttributeDecl();
fSchemaGrammar.getAttributeDecl(adeclIndex, adecl);
@@ -4512,7 +4512,7 @@
}
if (index == -1) {
// REVISIT: Add message. -Ac
- reportGenericSchemaError("no such element "+fStringPool.toString(nodeTest.name.localpart));
+ reportGenericSchemaError("no such element \""+fStringPool.toString(nodeTest.name.rawname)+'"');
return null;
}
edeclIndex = index;
1.5 +3 -4 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java
Index: Field.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Field.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Field.java 2001/02/20 06:12:28 1.4
+++ Field.java 2001/02/20 07:47:05 1.5
@@ -67,7 +67,7 @@
* Schema identity constraint field.
*
* @author Andy Clark, IBM
- * @version $Id: Field.java,v 1.4 2001/02/20 06:12:28 andyc Exp $
+ * @version $Id: Field.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
public class Field {
@@ -149,13 +149,12 @@
/** Constructs a field XPath expression. */
public XPath(String xpath, StringPool stringPool,
- NamespacesScope context, int targetNamespace)
- throws XPathException {
+ NamespacesScope context) throws XPathException {
// NOTE: We have to prefix the field XPath with "./" in
// order to handle selectors such as "@attr" that
// select the attribute because the fields could be
// relative to the selector element. -Ac
- super("./"+xpath, stringPool, context, targetNamespace);
+ super("./"+xpath, stringPool, context);
} // <init>(String,StringPool,NamespacesScope)
} // class XPath
1.5 +4 -5 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java
Index: Selector.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/Selector.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Selector.java 2001/02/01 09:58:43 1.4
+++ Selector.java 2001/02/20 07:47:05 1.5
@@ -68,7 +68,7 @@
* Schema identity constraint selector.
*
* @author Andy Clark, IBM
- * @version $Id: Selector.java,v 1.4 2001/02/01 09:58:43 andyc Exp $
+ * @version $Id: Selector.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
public class Selector {
@@ -131,7 +131,7 @@
* Schema identity constraint selector XPath expression.
*
* @author Andy Clark, IBM
- * @version $Id: Selector.java,v 1.4 2001/02/01 09:58:43 andyc Exp $
+ * @version $Id: Selector.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
public static class XPath
extends org.apache.xerces.validators.schema.identity.XPath {
@@ -142,13 +142,12 @@
/** Constructs a selector XPath expression. */
public XPath(String xpath, StringPool stringPool,
- NamespacesScope context, int targetNamespace)
- throws XPathException {
+ NamespacesScope context) throws XPathException {
// NOTE: We have to prefix the selector XPath with "./" in
// order to handle selectors such as "." that select
// the element container because the fields could be
// relative to that element. -Ac
- super("./"+xpath, stringPool, context, targetNamespace);
+ super("./"+xpath, stringPool, context);
// verify that an attribute is not selected
XPath.Axis axis = fLocationPath.steps[fLocationPath.steps.length-1].axis;
1.5 +11 -17 xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java
Index: XPath.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/validators/schema/identity/XPath.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XPath.java 2001/02/01 09:58:44 1.4
+++ XPath.java 2001/02/20 07:47:05 1.5
@@ -65,7 +65,7 @@
* Bare minimum XPath parser.
*
* @author Andy Clark, IBM
- * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
+ * @version $Id: XPath.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
public class XPath {
@@ -100,11 +100,11 @@
/** Constructs an XPath object from the specified expression. */
public XPath(String xpath, StringPool stringPool,
- NamespacesScope context, int targetNamespace)
+ NamespacesScope context)
throws XPathException {
fExpression = xpath;
fStringPool = stringPool;
- parseExpression(context, targetNamespace);
+ parseExpression(context);
} // <init>(String,StringPool,NamespacesScope)
//
@@ -133,8 +133,8 @@
* This method is implemented by using the XPathExprScanner and
* examining the list of tokens that it returns.
*/
- private void parseExpression(final NamespacesScope context,
- int targetNamespace) throws XPathException {
+ private void parseExpression(final NamespacesScope context)
+ throws XPathException {
// tokens
final XPath.Tokens xtokens = new XPath.Tokens(fStringPool);
@@ -202,13 +202,10 @@
}
token = xtokens.getToken(++i);
int prefix = xtokens.getTokenString(token);
- int uri = -1;
+ int uri = StringPool.EMPTY_STRING;
if (context != null && prefix != -1) {
uri = context.getNamespaceForPrefix(prefix);
}
- if (uri == -1) {
- uri = targetNamespace;
- }
if (prefix != -1 && context != null && uri == StringPool.EMPTY_STRING) {
throw new XPathException("prefix "+fStringPool.toString(prefix)+" not bound to namespace URI");
}
@@ -247,13 +244,10 @@
// consume QName token
token = xtokens.getToken(++i);
int prefix = xtokens.getTokenString(token);
- int uri = -1;
+ int uri = StringPool.EMPTY_STRING;
if (context != null && prefix != -1) {
uri = context.getNamespaceForPrefix(prefix);
}
- if (uri == -1) {
- uri = targetNamespace;
- }
if (prefix != -1 && context != null &&
uri == StringPool.EMPTY_STRING) {
throw new XPathException("prefix "+fStringPool.toString(prefix)+" not bound to namespace URI");
@@ -612,7 +606,7 @@
* @author Glenn Marcy, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
+ * @version $Id: XPath.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
private static final class Tokens {
@@ -1070,7 +1064,7 @@
* @author Glenn Marcy, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
+ * @version $Id: XPath.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
private static class Scanner {
@@ -2148,7 +2142,7 @@
* @author Glenn Marcy, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XPath.java,v 1.4 2001/02/01 09:58:44 andyc Exp $
+ * @version $Id: XPath.java,v 1.5 2001/02/20 07:47:05 andyc Exp $
*/
/***
public static class XPathExprParser {
@@ -3607,7 +3601,7 @@
try {
StringPool stringPool = new StringPool();
XPath xpath = new XPath(expression, stringPool,
- null, StringPool.EMPTY_STRING);
+ null);
System.out.println("expanded xpath: \""+xpath.toString()+'"');
}
catch (XPathException e) {