mrglavas 2003/12/01 13:52:32
Modified: java/src/org/apache/xerces/impl/msg
XIncludeMessages.properties
java/src/org/apache/xerces/xinclude XIncludeHandler.java
Log:
Issue a warning to users of the old http://www.w3.org/2001/XInclude namespace.
See: http://www.w3.org/TR/2003/WD-xinclude-20031110/#syntax
Revision Changes Path
1.5 +3 -0
xml-xerces/java/src/org/apache/xerces/impl/msg/XIncludeMessages.properties
Index: XIncludeMessages.properties
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/msg/XIncludeMessages.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XIncludeMessages.properties 1 Dec 2003 04:51:07 -0000 1.4
+++ XIncludeMessages.properties 1 Dec 2003 21:52:32 -0000 1.5
@@ -16,6 +16,9 @@
NonDuplicateNotation = Multiple notations were used which had the name ''{0}'', but
which were not determined to be duplicates.
NonDuplicateUnparsedEntity = Multiple unparsed entities were used which had the
name ''{0}'', but which were not determined to be duplicates.
+# Warning Messages
+OldXIncludeNamespace = At least one 'include' or 'fallback' element in the document
is bound to the old ''http://www.w3.org/2001/XInclude'' namespace. This namespace is
no longer processed. The namespace ''http://www.w3.org/2003/XInclude'' must be used
for XInclude processing.
+
# Messages from erroneous set-up
IncompatibleNamespaceContext = The type of the NamespaceContext is incompatible
with using XInclude; it must be an instance of XIncludeNamespaceSupport
ExpandedSystemId = Could not expand system id of included resource
1.11 +53 -6
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java
Index: XIncludeHandler.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XIncludeHandler.java 1 Dec 2003 11:56:45 -0000 1.10
+++ XIncludeHandler.java 1 Dec 2003 21:52:32 -0000 1.11
@@ -145,6 +145,8 @@
public final static String XINCLUDE_NS_URI =
"http://www.w3.org/2003/XInclude".intern();
+ public final static String XINCLUDE_NS_URI_OLD =
+ "http://www.w3.org/2001/XInclude".intern();
public final static String XINCLUDE_INCLUDE = "include".intern();
public final static String XINCLUDE_FALLBACK = "fallback".intern();
@@ -284,6 +286,10 @@
// track the version of the document being parsed
private boolean fIsXML11;
+
+ // track whether a warning has already been reported for
+ // use of the old http://www.w3.org/2001/XInclude namespace.
+ private boolean fOldNamespaceWarningIssued;
// Constructors
@@ -313,6 +319,7 @@
fUnparsedEntities = new Vector();
fParentRelativeURI = null;
fIsXML11 = false;
+ fOldNamespaceWarningIssued = false;
baseURIScope.clear();
baseURI.clear();
@@ -1254,32 +1261,72 @@
* @return true if the element has the namespace
"http://www.w3.org/2003/XInclude"
*/
protected boolean hasXIncludeNamespace(QName element) {
+ // REVISIT: The namespace of this element should be bound
+ // already. Why are we looking it up from the namespace
+ // context? -- mrglavas
return element.uri == XINCLUDE_NS_URI
|| fNamespaceContext.getURI(element.prefix) == XINCLUDE_NS_URI;
}
+
+ /**
+ * Returns true if the element has the namespace
"http://www.w3.org/2001/XInclude"
+ * @param element the element to check
+ * @return true if the element has the namespace
"http://www.w3.org/2001/XInclude"
+ */
+ protected boolean hasXInclude2001Namespace(QName element) {
+ // REVISIT: The namespace of this element should be bound
+ // already. Why are we looking it up from the namespace
+ // context? -- mrglavas
+ return element.uri == XINCLUDE_NS_URI_OLD
+ || fNamespaceContext.getURI(element.prefix) == XINCLUDE_NS_URI_OLD;
+ }
/**
* Checks if the element is an <include> element. The element must have
- * the XInclude namespace, and a local name of "include"
+ * the XInclude namespace, and a local name of "include". If the local name
+ * is "include" and the namespace name is the old XInclude namespace
+ * "http://www.w3.org/2001/XInclude" a warning is issued the first time
+ * an element from the old namespace is encountered.
+ *
* @param element the element to check
* @return true if the element is an <include> element
* @see #hasXIncludeNamespace(QName)
*/
protected boolean isIncludeElement(QName element) {
- return element.localpart.equals(XINCLUDE_INCLUDE)
- && hasXIncludeNamespace(element);
+ if (element.localpart.equals(XINCLUDE_INCLUDE)) {
+ if (hasXIncludeNamespace(element)) {
+ return true;
+ }
+ else if (!fOldNamespaceWarningIssued &&
hasXInclude2001Namespace(element)) {
+ reportError("OldXIncludeNamespace", null,
XMLErrorReporter.SEVERITY_WARNING);
+ fOldNamespaceWarningIssued = true;
+ }
+ }
+ return false;
}
/**
* Checks if the element is an <fallback> element. The element must have
- * the XInclude namespace, and a local name of "fallback"
+ * the XInclude namespace, and a local name of "fallback". If the local name
+ * is "fallback" and the namespace name is the old XInclude namespace
+ * "http://www.w3.org/2001/XInclude" a warning is issued the first time
+ * an element from the old namespace is encountered.
+ *
* @param element the element to check
* @return true if the element is an <fallback; element
* @see #hasXIncludeNamespace(QName)
*/
protected boolean isFallbackElement(QName element) {
- return element.localpart.equals(XINCLUDE_FALLBACK)
- && hasXIncludeNamespace(element);
+ if (element.localpart.equals(XINCLUDE_FALLBACK)) {
+ if (hasXIncludeNamespace(element)) {
+ return true;
+ }
+ else if (!fOldNamespaceWarningIssued &&
hasXInclude2001Namespace(element)) {
+ reportError("OldXIncludeNamespace", null,
XMLErrorReporter.SEVERITY_WARNING);
+ fOldNamespaceWarningIssued = true;
+ }
+ }
+ return false;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]