You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2003/06/24 23:56:59 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/util NamespaceSupport.java
elena 2003/06/24 14:56:59
Modified: java/src/org/apache/xerces/impl Constants.java
XMLDocumentScannerImpl.java
java/src/org/apache/xerces/util NamespaceSupport.java
Added: java/src/org/apache/xerces/impl/msg
XIncludeMessages.properties
java/src/org/apache/xerces/parsers
XIncludeParserConfiguration.java
Log:
The preliminary implementation of XInclude submitted by Peter McCracken.
It supports most normal functions: regular includes, text includes,
fallbacks, namespace fix-up, etc, and it should be okay for regular use.
The main functionality that is currently missing:
- XPointer support.
- Fix-up of unparsed entities and notations.
- Encoding of included documents when parse="text".
Revision Changes Path
1.30 +7 -1 xml-xerces/java/src/org/apache/xerces/impl/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- Constants.java 10 Jun 2003 17:42:58 -0000 1.29
+++ Constants.java 24 Jun 2003 21:56:58 -0000 1.30
@@ -289,6 +289,9 @@
/** Error handler property ("internal/error-handler"). */
public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
+ /** XInclude handler property ("internal/xinclude-handler"). */
+ public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler";
+
/** Entity manager property ("internal/entity-manager"). */
public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
@@ -333,6 +336,9 @@
/** Namespace binder property ("internal/namespace-binder"). */
public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder";
+
+ /** Namespace context property ("internal/namespace-context"). */
+ public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
/** Validation manager property ("internal/validation-manager"). */
public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
1.33 +25 -5 xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java
Index: XMLDocumentScannerImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XMLDocumentScannerImpl.java 16 Dec 2002 01:26:19 -0000 1.32
+++ XMLDocumentScannerImpl.java 24 Jun 2003 21:56:58 -0000 1.33
@@ -143,10 +143,14 @@
protected static final String DTD_SCANNER =
Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
- // property identifier: ValidationManager
+ /** property identifier: ValidationManager */
protected static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+ /** property identifier: NamespaceContext */
+ protected static final String NAMESPACE_CONTEXT =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -164,13 +168,15 @@
/** Recognized properties. */
private static final String[] RECOGNIZED_PROPERTIES = {
DTD_SCANNER,
- VALIDATION_MANAGER
+ VALIDATION_MANAGER,
+ NAMESPACE_CONTEXT,
};
/** Property defaults. */
private static final Object[] PROPERTY_DEFAULTS = {
null,
- null
+ null,
+ null,
};
//
@@ -293,7 +299,6 @@
fDoctypePublicId = null;
fDoctypeSystemId = null;
fSeenDoctypeDecl = false;
- fNamespaceContext.reset();
// xerces features
try {
@@ -318,6 +323,15 @@
fValidationManager = null;
}
+ try {
+ fNamespaceContext = (NamespaceContext)componentManager.getProperty(NAMESPACE_CONTEXT);
+ }
+ catch (XMLConfigurationException e) { }
+ if (fNamespaceContext == null) {
+ fNamespaceContext = new NamespaceSupport();
+ }
+ fNamespaceContext.reset();
+
// initialize vars
fScanningDTD = false;
@@ -420,6 +434,12 @@
if (property.equals(Constants.DTD_SCANNER_PROPERTY)) {
fDTDScanner = (XMLDTDScanner)value;
}
+ if (property.equals(Constants.NAMESPACE_CONTEXT_PROPERTY)) {
+ if (value != null) {
+ fNamespaceContext = (NamespaceContext)value;
+ }
+ }
+
return;
}
1.1 xml-xerces/java/src/org/apache/xerces/impl/msg/XIncludeMessages.properties
Index: XIncludeMessages.properties
===================================================================
# Messages for message reporting
BadMessageKey = The error message corresponding to the message key can not be found.
FormatFailed = An internal error occurred while formatting the following message:\n
# Messages for erroneous input
NoFallback = An 'include' failed, and no 'fallback' element was found.
MultipleFallbacks = The [children] of an 'include' element cannot contain more than one 'fallback' element.
FallbackParent = An 'include' element is not parent of 'fallback' element.
IncludeParent = The parent of an 'include' element cannot be another 'include' element.
HrefMissing = The 'href' attribute of an 'include' element is missing.
RecursiveInclude = Recursive include detected.
InvalidParseValue = Invalid value for ''parse'' attribute on ''include'' element: ''{0}''.
XMLParseError = Error parsing invalid XML file.
XMLResourceError = Resource error reading XML file. Reason: {0}
TextResourceError = Resource error reading text file. Reason: {0}
# 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.1 xml-xerces/java/src/org/apache/xerces/parsers/XIncludeParserConfiguration.java
Index: XIncludeParserConfiguration.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xerces" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2003, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xerces.parsers;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xinclude.XIncludeHandler;
import org.apache.xerces.xinclude.XIncludeNamespaceSupport;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.grammars.XMLGrammarPool;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLDocumentSource;
/**
* @author Peter McCracken, IBM
*/
public class XIncludeParserConfiguration extends XML11Configuration {
private XIncludeHandler fXIncludeComponent;
/** Property identifier: error reporter. */
protected static final String XINCLUDE_HANDLER =
Constants.XERCES_PROPERTY_PREFIX + Constants.XINCLUDE_HANDLER_PROPERTY;
/** Property identifier: error reporter. */
protected static final String NAMESPACE_CONTEXT =
Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
/** Default constructor. */
public XIncludeParserConfiguration() {
this(null, null, null);
//this(null, new XMLGrammarPoolImpl(), null);
} // <init>()
/**
* Constructs a parser configuration using the specified symbol table.
*
* @param symbolTable The symbol table to use.
*/
public XIncludeParserConfiguration(SymbolTable symbolTable) {
this(symbolTable, null, null);
//this(symbolTable, new XMLGrammarPoolImpl(), null);
} // <init>(SymbolTable)
/**
* Constructs a parser configuration using the specified symbol table and
* grammar pool.
* <p>
* <strong>REVISIT:</strong>
* Grammar pool will be updated when the new validation engine is
* implemented.
*
* @param symbolTable The symbol table to use.
* @param grammarPool The grammar pool to use.
*/
public XIncludeParserConfiguration(
SymbolTable symbolTable,
XMLGrammarPool grammarPool) {
this(symbolTable, grammarPool, null);
} // <init>(SymbolTable,XMLGrammarPool)
/**
* Constructs a parser configuration using the specified symbol table,
* grammar pool, and parent settings.
* <p>
* <strong>REVISIT:</strong>
* Grammar pool will be updated when the new validation engine is
* implemented.
*
* @param symbolTable The symbol table to use.
* @param grammarPool The grammar pool to use.
* @param parentSettings The parent settings.
*/
public XIncludeParserConfiguration(
SymbolTable symbolTable,
XMLGrammarPool grammarPool,
XMLComponentManager parentSettings) {
super(symbolTable, grammarPool, parentSettings);
final String[] recognizedFeatures = {
// XINCLUDE_PROCESSING TODO: should this be a feature?
};
addRecognizedFeatures(recognizedFeatures);
// add default recognized properties
final String[] recognizedProperties =
{ XINCLUDE_HANDLER, NAMESPACE_CONTEXT };
addRecognizedProperties(recognizedProperties);
setProperty(NAMESPACE_CONTEXT, new XIncludeNamespaceSupport());
fXIncludeComponent = new XIncludeHandler();
setProperty(XINCLUDE_HANDLER, fXIncludeComponent);
addComponent(fXIncludeComponent);
} // <init>(SymbolTable,XMLGrammarPool)}
/** Configures the pipeline. */
protected void configurePipeline() {
super.configurePipeline();
// setup document pipeline
// TODO: actually use XINCLUDE_PROCESSING feature, if we decide to implement it
if (true /*fFeatures.get(XINCLUDE_PROCESSING) == Boolean.TRUE*/
) {
if (fXIncludeComponent == null) {
fXIncludeComponent = new XIncludeHandler();
addComponent(fXIncludeComponent);
}
// insert before fSchemaValidator, if one exists.
XMLDocumentSource prev = null;
if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) {
// we don't have to worry about fSchemaValidator being null, since
// super.configurePipeline() instantiated it if the feature was set
prev = fSchemaValidator.getDocumentSource();
}
// Otherwise, insert after the last component in the pipeline
else {
prev = fLastComponent;
}
if (prev != null) {
XMLDocumentHandler next = prev.getDocumentHandler();
if (next != null) {
fXIncludeComponent.setDocumentHandler(next);
next.setDocumentSource(fXIncludeComponent);
}
prev.setDocumentHandler(fXIncludeComponent);
fXIncludeComponent.setDocumentSource(prev);
}
else {
setDocumentHandler(fXIncludeComponent);
}
}
} // configurePipeline()
}
1.16 +2 -2 xml-xerces/java/src/org/apache/xerces/util/NamespaceSupport.java
Index: NamespaceSupport.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/util/NamespaceSupport.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- NamespaceSupport.java 17 Feb 2003 18:06:27 -0000 1.15
+++ NamespaceSupport.java 24 Jun 2003 21:56:59 -0000 1.16
@@ -301,7 +301,7 @@
return new Prefixes(fPrefixes, count);
}
- final class Prefixes implements Enumeration {
+ protected final class Prefixes implements Enumeration {
private String[] prefixes;
private int counter = 0;
private int size = 0;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org