You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/06/11 04:34:53 UTC
svn commit: r545991 - in
/xerces/java/branches/stax-dev/src/org/apache/xerces/stax:
AbstractStAXParser.java StAXLocation.java StAXNamespaceContext.java
StAXParser.java XMLInputFactoryImpl.java
Author: mrglavas
Date: Sun Jun 10 19:34:52 2007
New Revision: 545991
URL: http://svn.apache.org/viewvc?view=rev&rev=545991
Log:
Fixing JIRA Issue #1253:
http://issues.apache.org/jira/browse/XERCESJ-1253
Initial XMLStreamReader prototyping from Wei Duan:
"This prototype validates the technical mechanism which builds StAX parser based on XNI and implements
intital XNI-based XMLStreamReader. The work done in the prototype also includes:
* Use XMLPullConfiguration to simulate stax parsing process.
* Implement element, attribute, text, namespacecontext, location methods."
Added:
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java (with props)
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java (with props)
Modified:
xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java?view=auto&rev=545991
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java Sun Jun 10 19:34:52 2007
@@ -0,0 +1,926 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import javax.xml.stream.XMLStreamConstants;
+
+import org.apache.xerces.parsers.AbstractXMLDocumentParser;
+import org.apache.xerces.parsers.XML11Configuration;
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.NamespaceContext;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.xni.XMLLocator;
+import org.apache.xerces.xni.XMLResourceIdentifier;
+import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.XNIException;
+
+/**
+ * @author Wei Duan
+ *
+ * @version $Id$
+ */
+public class AbstractStAXParser extends AbstractXMLDocumentParser {
+ // Represent the XNI type such as xmlDecl but not existed in stax
+ // TODO : The parsing steps of XNI and StAX are not the same. For example,
+ // XNI will treat
+ // START_DOCUMENT and XML_DECL as two events, and stax will treat as one
+ static protected int START_DOCUMENT_DECL = -1;
+
+ // The current event type
+ protected int eventType;
+
+ // Document encoding style
+ protected String encodingDoc = null;
+
+ // XML document version
+ protected String versionXML = null;
+
+ // XML encoding style
+ protected String encodingXML = null;
+
+ // Standalone description
+ protected String standaloneXML = null;
+
+ // Process Instruction target
+ protected String piTarget = null;
+
+ // Character content
+ protected XMLString characters = null;
+
+ // Process Instruction data
+ protected XMLString piData = null;
+
+ // Comment data
+ protected XMLString comment = null;
+
+ // Element QName
+ protected QName elementName = null;
+
+ // Element attribute
+ // TODO : Actually, a attribute stack is needed to store the attribute for
+ // endElement event
+ protected XMLAttributes elementAttr = null;
+
+ // Namespace context
+ protected NamespaceContext namespaceContext = null;
+
+ // XML locator
+ protected XMLLocator locator = null;
+
+ //
+ // Constructors
+ //
+ /** Default constructor. */
+ protected AbstractStAXParser(XML11Configuration configuration) {
+ super(configuration);
+
+ // TODO: Investigate and make clear StAX related features
+ configuration.setFeature(
+ "http://apache.org/xml/features/allow-java-encodings", true);
+
+ } // <init>(XML11Configuration)
+
+ /**
+ * reset all components before parsing
+ */
+ protected void reset() throws XNIException {
+ super.reset();
+
+ versionXML = null;
+ encodingXML = null;
+ standaloneXML = null;
+ characters = null;
+ piTarget = null;
+ piData = null;
+ elementName = null;
+ elementAttr = null;
+ namespaceContext = null;
+ } // reset()
+
+ //
+ // XMLDocumentHandler methods
+ //
+
+ /**
+ * The start of the document.
+ *
+ * @param locator
+ * The system identifier of the entity if the entity is external,
+ * null otherwise.
+ * @param encoding
+ * The auto-detected IANA encoding name of the entity stream.
+ * This value will be null in those situations where the entity
+ * encoding is not auto-detected (e.g. internal entities or a
+ * document entity that is parsed from a java.io.Reader).
+ * @param namespaceContext
+ * The namespace context in effect at the start of this document.
+ * This object represents the current context. Implementors of
+ * this class are responsible for copying the namespace bindings
+ * from the the current context (and its parent contexts) if that
+ * information is important.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+
+ public void startDocument(XMLLocator locator, String encoding,
+ NamespaceContext namespaceContext, Augmentations augs)
+ throws XNIException {
+ eventType = XMLStreamConstants.START_DOCUMENT;
+ this.locator = locator;
+ this.namespaceContext = namespaceContext;
+ this.encodingDoc = encoding;
+ } // startDocument(XMLLocator,String)
+
+ /**
+ * Notifies of the presence of an XMLDecl line in the document. If present,
+ * this method will be called immediately following the startDocument call.
+ *
+ * @param version
+ * The XML version.
+ * @param encoding
+ * The IANA encoding name of the document, or null if not
+ * specified.
+ * @param standalone
+ * The standalone value, or null if not specified.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void xmlDecl(String version, String encoding, String standalone,
+ Augmentations augs) throws XNIException {
+ this.versionXML = version;
+ this.encodingXML = encoding;
+ this.standaloneXML = standalone;
+
+ // No according event type in stax event
+ eventType = START_DOCUMENT_DECL;
+ } // xmlDecl(String,String,String)
+
+ /**
+ * Notifies of the presence of the DOCTYPE line in the document.
+ *
+ * @param rootElement
+ * The name of the root element.
+ * @param publicId
+ * The public identifier if an external DTD or null if the
+ * external DTD is specified using SYSTEM.
+ * @param systemId
+ * The system identifier if an external DTD, null
+ * @param augs
+ * Additional information that may include infoset augmentations
+ * otherwise.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void doctypeDecl(String rootElement, String publicId,
+ String systemId, Augmentations augs) throws XNIException {
+
+ } // doctypeDecl(String,String,String)
+
+ /**
+ * The start of an element. If the document specifies the start element by
+ * using an empty tag, then the startElement method will immediately be
+ * followed by the endElement method, with no intervening methods.
+ *
+ * @param element
+ * The name of the element.
+ * @param attributes
+ * The element attributes.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startElement(QName element, XMLAttributes attributes,
+ Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.START_ELEMENT;
+
+ this.elementName = element;
+ this.elementAttr = attributes;
+ } // startElement(QName,XMLAttributes)
+
+ /**
+ * An empty element.
+ *
+ * @param element
+ * The name of the element.
+ * @param attributes
+ * The element attributes.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void emptyElement(QName element, XMLAttributes attributes,
+ Augmentations augs) throws XNIException {
+
+ // Assume that type of empty element is START_ELEMENT
+ eventType = XMLStreamConstants.START_ELEMENT;
+
+ startElement(element, attributes, augs);
+ endElement(element, augs);
+ } // emptyElement(QName,XMLAttributes)
+
+ /**
+ * Character content.
+ *
+ * @param text
+ * The content.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void characters(XMLString text, Augmentations augs)
+ throws XNIException {
+ eventType = XMLStreamConstants.CHARACTERS;
+ this.characters = text;
+
+ } // characters(XMLString)
+
+ /**
+ * Ignorable whitespace. For this method to be called, the document source
+ * must have some way of determining that the text containing only
+ * whitespace characters should be considered ignorable. For example, the
+ * validator can determine if a length of whitespace characters in the
+ * document are ignorable based on the element content model.
+ *
+ * @param text
+ * The ignorable whitespace.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void ignorableWhitespace(XMLString text, Augmentations augs)
+ throws XNIException {
+ eventType = XMLStreamConstants.SPACE;
+ this.characters = text;
+ } // ignorableWhitespace(XMLString)
+
+ /**
+ * The end of an element.
+ *
+ * @param element
+ * The name of the element.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endElement(QName element, Augmentations augs)
+ throws XNIException {
+ eventType = XMLStreamConstants.END_ELEMENT;
+
+ this.elementName = element;
+ } // endElement(QName)
+
+ /**
+ * The start of a CDATA section.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startCDATA(Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.CDATA;
+ } // startCDATA()
+
+ /**
+ * The end of a CDATA section.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endCDATA(Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.CDATA;
+ } // endCDATA()
+
+ /**
+ * The end of the document.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endDocument(Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.END_DOCUMENT;
+ } // endDocument()
+
+ /**
+ * This method notifies the start of an entity.
+ * <p>
+ * <strong>Note:</strong> This method is not called for entity references
+ * appearing as part of attribute values.
+ *
+ * @param name
+ * The name of the entity.
+ * @param identifier
+ * The resource identifier.
+ * @param encoding
+ * The auto-detected IANA encoding name of the entity stream.
+ * This value will be null in those situations where the entity
+ * encoding is not auto-detected (e.g. internal entities or a
+ * document entity that is parsed from a java.io.Reader).
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startGeneralEntity(String name,
+ XMLResourceIdentifier identifier, String encoding,
+ Augmentations augs) throws XNIException {
+ } // startGeneralEntity(String,XMLResourceIdentifier,String,Augmentations)
+
+ /**
+ * Notifies of the presence of a TextDecl line in an entity. If present,
+ * this method will be called immediately following the startEntity call.
+ * <p>
+ * <strong>Note:</strong> This method will never be called for the document
+ * entity; it is only called for external general entities referenced in
+ * document content.
+ * <p>
+ * <strong>Note:</strong> This method is not called for entity references
+ * appearing as part of attribute values.
+ *
+ * @param version
+ * The XML version, or null if not specified.
+ * @param encoding
+ * The IANA encoding name of the entity.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void textDecl(String version, String encoding, Augmentations augs)
+ throws XNIException {
+ } // textDecl(String, String, Augmentations)
+
+ /**
+ * This method notifies the end of an entity.
+ * <p>
+ * <strong>Note:</strong> This method is not called for entity references
+ * appearing as part of attribute values.
+ *
+ * @param name
+ * The name of the entity.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endGeneralEntity(String name, Augmentations augs)
+ throws XNIException {
+ } // endGeneralEntity(String,Augmentations)
+
+ /**
+ * A comment.
+ *
+ * @param text
+ * The text in the comment.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by application to signal an error.
+ */
+ public void comment(XMLString text, Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.COMMENT;
+ this.comment = text;
+ } // comment (XMLString, Augmentations)
+
+ /**
+ * A processing instruction. Processing instructions consist of a target
+ * name and, optionally, text data. The data is only meaningful to the
+ * application.
+ * <p>
+ * Typically, a processing instruction's data will contain a series of
+ * pseudo-attributes. These pseudo-attributes follow the form of element
+ * attributes but are <strong>not</strong> parsed or presented to the
+ * application as anything other than text. The application is responsible
+ * for parsing the data.
+ *
+ * @param target
+ * The target.
+ * @param data
+ * The data or null if none specified.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void processingInstruction(String target, XMLString data,
+ Augmentations augs) throws XNIException {
+ eventType = XMLStreamConstants.PROCESSING_INSTRUCTION;
+
+ this.piData = data;
+ this.piTarget = target;
+ } // processingInstruction(String, XMLString, Augmentations)
+
+ //
+ // XMLDTDHandler methods
+ //
+
+ /**
+ * The start of the DTD.
+ *
+ * @param locator
+ * The document locator, or null if the document location cannot
+ * be reported during the parsing of the document DTD. However,
+ * it is <em>strongly</em> recommended that a locator be
+ * supplied that can at least report the base system identifier
+ * of the DTD.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startDTD(XMLLocator locator, Augmentations augs)
+ throws XNIException {
+ fInDTD = true;
+ } // startDTD(XMLLocator)
+
+ /**
+ * The start of the DTD external subset.
+ *
+ * @param augmentations
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startExternalSubset(XMLResourceIdentifier identifier,
+ Augmentations augmentations) throws XNIException {
+ } // startExternalSubset(Augmentations)
+
+ /**
+ * The end of the DTD external subset.
+ *
+ * @param augmentations
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endExternalSubset(Augmentations augmentations)
+ throws XNIException {
+ } // endExternalSubset(Augmentations)
+
+ /**
+ * This method notifies the start of an entity.
+ * <p>
+ * <strong>Note:</strong> This method is not called for entity references
+ * appearing as part of attribute values.
+ *
+ * @param name
+ * The name of the entity.
+ * @param identifier
+ * The resource identifier.
+ * @param encoding
+ * The auto-detected IANA encoding name of the entity stream.
+ * This value will be null in those situations where the entity
+ * encoding is not auto-detected (e.g. internal entities or a
+ * document entity that is parsed from a java.io.Reader).
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startParameterEntity(String name,
+ XMLResourceIdentifier identifier, String encoding,
+ Augmentations augs) throws XNIException {
+ } // startParameterEntity(String,XMLResourceIdentifier,String,Augmentations)
+
+ /**
+ * This method notifies the end of an entity.
+ * <p>
+ * <strong>Note:</strong> This method is not called for entity references
+ * appearing as part of attribute values.
+ *
+ * @param name
+ * The name of the entity.
+ * @param augs
+ * Additional information that may include infoset augmentations
+ *
+ * @exception XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endParameterEntity(String name, Augmentations augs)
+ throws XNIException {
+ } // endParameterEntity(String,Augmentations)
+
+ /**
+ * Characters within an IGNORE conditional section.
+ *
+ * @param text
+ * The ignored text.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void ignoredCharacters(XMLString text, Augmentations augs)
+ throws XNIException {
+ } // ignoredCharacters(XMLString, Augmentations)
+
+ /**
+ * An element declaration.
+ *
+ * @param name
+ * The name of the element.
+ * @param contentModel
+ * The element content model.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void elementDecl(String name, String contentModel, Augmentations augs)
+ throws XNIException {
+ } // elementDecl(String,String)
+
+ /**
+ * The start of an attribute list.
+ *
+ * @param elementName
+ * The name of the element that this attribute list is associated
+ * with.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startAttlist(String elementName, Augmentations augs)
+ throws XNIException {
+ } // startAttlist(String)
+
+ /**
+ * An attribute declaration.
+ *
+ * @param elementName
+ * The name of the element that this attribute is associated
+ * with.
+ * @param attributeName
+ * The name of the attribute.
+ * @param type
+ * The attribute type. This value will be one of the following:
+ * "CDATA", "ENTITY", "ENTITIES", "ENUMERATION", "ID", "IDREF",
+ * "IDREFS", "NMTOKEN", "NMTOKENS", or "NOTATION".
+ * @param enumeration
+ * If the type has the value "ENUMERATION" or "NOTATION", this
+ * array holds the allowed attribute values; otherwise, this
+ * array is null.
+ * @param defaultType
+ * The attribute default type. This value will be one of the
+ * following: "#FIXED", "#IMPLIED", "#REQUIRED", or null.
+ * @param defaultValue
+ * The attribute default value, or null if no default value is
+ * specified.
+ * @param nonNormalizedDefaultValue
+ * The attribute default value with no normalization performed,
+ * or null if no default value is specified.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void attributeDecl(String elementName, String attributeName,
+ String type, String[] enumeration, String defaultType,
+ XMLString defaultValue, XMLString nonNormalizedDefaultValue,
+ Augmentations augs) throws XNIException {
+ } // attributeDecl(String,String,String,String[],String,XMLString,
+ // XMLString, Augmentations)
+
+ /**
+ * The end of an attribute list.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endAttlist(Augmentations augs) throws XNIException {
+ } // endAttlist()
+
+ /**
+ * An internal entity declaration.
+ *
+ * @param name
+ * The name of the entity. Parameter entity names start with '%',
+ * whereas the name of a general entity is just the entity name.
+ * @param text
+ * The value of the entity.
+ * @param nonNormalizedText
+ * The non-normalized value of the entity. This value contains
+ * the same sequence of characters that was in the internal
+ * entity declaration, without any entity references expanded.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void internalEntityDecl(String name, XMLString text,
+ XMLString nonNormalizedText, Augmentations augs)
+ throws XNIException {
+ } // internalEntityDecl(String,XMLString,XMLString)
+
+ /**
+ * An external entity declaration.
+ *
+ * @param name
+ * The name of the entity. Parameter entity names start with '%',
+ * whereas the name of a general entity is just the entity name.
+ * @param identifier
+ * An object containing all location information pertinent to
+ * this entity.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void externalEntityDecl(String name,
+ XMLResourceIdentifier identifier, Augmentations augs)
+ throws XNIException {
+ } // externalEntityDecl(String,XMLResourceIdentifier, Augmentations)
+
+ /**
+ * An unparsed entity declaration.
+ *
+ * @param name
+ * The name of the entity.
+ * @param identifier
+ * An object containing all location information pertinent to
+ * this entity.
+ * @param notation
+ * The name of the notation.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void unparsedEntityDecl(String name,
+ XMLResourceIdentifier identifier, String notation,
+ Augmentations augs) throws XNIException {
+ } // unparsedEntityDecl(String,XMLResourceIdentifier, String,
+ // Augmentations)
+
+ /**
+ * A notation declaration
+ *
+ * @param name
+ * The name of the notation.
+ * @param identifier
+ * An object containing all location information pertinent to
+ * this notation.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void notationDecl(String name, XMLResourceIdentifier identifier,
+ Augmentations augs) throws XNIException {
+ } // notationDecl(String,XMLResourceIdentifier, Augmentations)
+
+ /**
+ * The start of a conditional section.
+ *
+ * @param type
+ * The type of the conditional section. This value will either be
+ * CONDITIONAL_INCLUDE or CONDITIONAL_IGNORE.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #CONDITIONAL_INCLUDE
+ * @see #CONDITIONAL_IGNORE
+ */
+ public void startConditional(short type, Augmentations augs)
+ throws XNIException {
+ } // startConditional(short)
+
+ /**
+ * The end of a conditional section.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endConditional(Augmentations augs) throws XNIException {
+ } // endConditional()
+
+ //
+ // XMLDTDContentModelHandler methods
+ //
+
+ /**
+ * The start of a content model. Depending on the type of the content model,
+ * specific methods may be called between the call to the startContentModel
+ * method and the call to the endContentModel method.
+ *
+ * @param elementName
+ * The name of the element.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void startContentModel(String elementName, Augmentations augs)
+ throws XNIException {
+ } // startContentModel(String, Augmentations)
+
+ /**
+ * A content model of ANY.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #empty
+ * @see #startGroup
+ */
+ public void any(Augmentations augs) throws XNIException {
+ } // any(Augmentations)
+
+ /**
+ * A content model of EMPTY.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #any
+ * @see #startGroup
+ */
+ public void empty(Augmentations augs) throws XNIException {
+ } // empty(Augmentations)
+
+ /**
+ * A start of either a mixed or children content model. A mixed content
+ * model will immediately be followed by a call to the <code>pcdata()</code>
+ * method. A children content model will contain additional groups and/or
+ * elements.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #any
+ * @see #empty
+ */
+ public void startGroup(Augmentations augs) throws XNIException {
+ } // stargGroup(Augmentations)
+
+ /**
+ * The appearance of "#PCDATA" within a group signifying a mixed content
+ * model. This method will be the first called following the content model's
+ * <code>startGroup()</code>.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #startGroup
+ */
+ public void pcdata(Augmentations augs) throws XNIException {
+ } // pcdata(Augmentations)
+
+ /**
+ * A referenced element in a mixed or children content model.
+ *
+ * @param elementName
+ * The name of the referenced element.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void element(String elementName, Augmentations augs)
+ throws XNIException {
+ } // element(String, Augmentations)
+
+ /**
+ * The separator between choices or sequences of a mixed or children content
+ * model.
+ *
+ * @param separator
+ * The type of children separator.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #SEPARATOR_CHOICE
+ * @see #SEPARATOR_SEQUENCE
+ */
+ public void separator(short separator, Augmentations augs)
+ throws XNIException {
+ } // separator(short, Augmentations)
+
+ /**
+ * The occurrence count for a child in a children content model or for the
+ * mixed content model group.
+ *
+ * @param occurrence
+ * The occurrence count for the last element or group.
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ *
+ * @see #OCCURS_ZERO_OR_ONE
+ * @see #OCCURS_ZERO_OR_MORE
+ * @see #OCCURS_ONE_OR_MORE
+ */
+ public void occurrence(short occurrence, Augmentations augs)
+ throws XNIException {
+ } // occurence(short, Augmentations)
+
+ /**
+ * The end of a group for mixed or children content models.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endGroup(Augmentations augs) throws XNIException {
+ } // endGroup(Augmentations)
+
+ /**
+ * The end of a content model.
+ *
+ * @param augs
+ * Additional information that may include infoset augmentations.
+ *
+ * @throws XNIException
+ * Thrown by handler to signal an error.
+ */
+ public void endContentModel(Augmentations augs) throws XNIException {
+ } // endContentModel(Augmentations)
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/AbstractStAXParser.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java?view=auto&rev=545991
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java Sun Jun 10 19:34:52 2007
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import javax.xml.stream.Location;
+import org.apache.xerces.xni.XMLLocator;
+
+/**
+ * @author Wei Duan
+ *
+ * @version $Id$
+ */
+public class StAXLocation implements Location {
+
+ private XMLLocator xniLocator;
+
+ public StAXLocation(XMLLocator loc) {
+ this.xniLocator = loc;
+ }
+
+ /**
+ * Return the line number where the current event ends, returns -1 if none
+ * is available.
+ *
+ * @return the current line number
+ */
+ public int getLineNumber() {
+ return xniLocator.getLineNumber();
+ }
+
+ /**
+ * Return the column number where the current event ends, returns -1 if none
+ * is available.
+ *
+ * @return the current column number
+ */
+ public int getColumnNumber() {
+ return xniLocator.getColumnNumber();
+ }
+
+ /**
+ * Return the byte or character offset into the input source this location
+ * is pointing to. If the input source is a file or a byte stream then this
+ * is the byte offset into that stream, but if the input source is a
+ * character media then the offset is the character offset. Returns -1 if
+ * there is no offset available.
+ *
+ * @return the current offset
+ */
+ public int getCharacterOffset() {
+ return xniLocator.getCharacterOffset();
+ }
+
+ /**
+ * Returns the public ID of the XML
+ *
+ * @return the public ID, or null if not available
+ */
+ public String getPublicId() {
+ return xniLocator.getPublicId();
+ }
+
+ /**
+ * Returns the system ID of the XML
+ *
+ * @return the system ID, or null if not available
+ */
+ public String getSystemId() {
+ return xniLocator.getBaseSystemId();
+ }
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXLocation.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java?view=auto&rev=545991
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java Sun Jun 10 19:34:52 2007
@@ -0,0 +1,218 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import java.util.Iterator;
+
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * @author Wei Duan
+ *
+ * @version $Id$
+ */
+public class StAXNamespaceContext implements NamespaceContext {
+ private org.apache.xerces.xni.NamespaceContext namespaceContext;
+
+ public StAXNamespaceContext(
+ org.apache.xerces.xni.NamespaceContext xniContext) {
+ this.namespaceContext = xniContext;
+ }
+
+ /**
+ * Get Namespace URI bound to a prefix in the current scope.
+ *
+ * <p>
+ * When requesting a Namespace URI by prefix, the following table describes
+ * the returned Namespace URI value for all possible prefix values:
+ * </p>
+ *
+ * <table border="2" rules="all" cellpadding="4"> <thead>
+ * <tr>
+ * <th align="center" colspan="2"> <code>getNamespaceURI(prefix)</code>
+ * return value for specified prefixes </th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr>
+ * <th>prefix parameter</th>
+ * <th>Namespace URI return value</th>
+ * </tr>
+ * <tr>
+ * <td><code>DEFAULT_NS_PREFIX</code> ("")</td>
+ * <td>default Namespace URI in the current scope or <code>null</code>
+ * when there is no default Namespace URI in the current scope</td>
+ * </tr>
+ * <tr>
+ * <td>bound prefix</td>
+ * <td>Namespace URI bound to prefix in current scope</td>
+ * </tr>
+ * <tr>
+ * <td>unbound prefix</td>
+ * <td><code>null</code></td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+ * <td><code>XMLConstants.XML_NS_URI</code>
+ * ("http://www.w3.org/XML/1998/namespace")</td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+ * <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+ * ("http://www.w3.org/2000/xmlns/")</td>
+ * </tr>
+ * <tr>
+ * <td><code>null</code></td>
+ * <td><code>IllegalArgumentException</code> is thrown</td>
+ * </tr>
+ * </tbody> </table>
+ *
+ * @param prefix
+ * prefix to look up
+ * @return Namespace URI bound to prefix in the current scope
+ */
+ public String getNamespaceURI(String prefix) {
+ return namespaceContext.getURI(prefix);
+ }
+
+ /**
+ * Get prefix bound to Namespace URI in the current scope.
+ *
+ * <p>
+ * To get all prefixes bound to a Namespace URI in the current scope, use
+ * {@link #getPrefixes(String namespaceURI)}.
+ * </p>
+ *
+ * <p>
+ * When requesting a prefix by Namespace URI, the following table describes
+ * the returned prefix value for all Namespace URI values:
+ * </p>
+ *
+ * <table border="2" rules="all" cellpadding="4"> <thead>
+ * <tr>
+ * <th align="center" colspan="2"> <code>getPrefix(namespaceURI)</code>
+ * return value for specified Namespace URIs </th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr>
+ * <th>Namespace URI parameter</th>
+ * <th>prefix value returned</th>
+ * </tr>
+ * <tr>
+ * <td><default Namespace URI></td>
+ * <td><code>XMLConstants.DEFAULT_NS_PREFIX</code> ("") </td>
+ * </tr>
+ * <tr>
+ * <td>bound Namespace URI</td>
+ * <td>prefix bound to Namespace URI in the current scope, if multiple
+ * prefixes are bound to the Namespace URI in the current scope, a single
+ * arbitrary prefix, whose choice is implementation dependent, is returned</td>
+ * </tr>
+ * <tr>
+ * <td>unbound Namespace URI</td>
+ * <td><code>null</code></td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XML_NS_URI</code>
+ * ("http://www.w3.org/XML/1998/namespace")</td>
+ * <td><code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+ * ("http://www.w3.org/2000/xmlns/")</td>
+ * <td><code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+ * </tr>
+ * <tr>
+ * <td><code>""</code> or <code>null</code></td>
+ * <td><code>IllegalArgumentException</code> is thrown</td>
+ * </tr>
+ * </tbody> </table>
+ *
+ * @param namespaceURI
+ * URI of Namespace to lookup
+ * @return prefix bound to Namespace URI in current context
+ */
+ public String getPrefix(String namespaceURI) {
+ return namespaceContext.getPrefix(namespaceURI);
+ }
+
+ /**
+ * Get all prefixes bound to a Namespace URI in the current scope.
+ *
+ * <p>
+ * <strong>The returned <code>Iterator</code> is <em>not</em>
+ * modifiable. e.g. the <code>remove()</code> method will throw
+ * <code>NoSuchMethodException</code>.</strong>
+ * </p>
+ *
+ * <p>
+ * Prefixes are returned in an arbitrary, implementation dependent, order.
+ * </p>
+ *
+ * <p>
+ * When requesting prefixes by Namespace URI, the following table describes
+ * the returned prefixes value for all Namespace URI values:
+ * </p>
+ *
+ * <table border="2" rules="all" cellpadding="4"> <thead>
+ * <tr>
+ * <th align="center" colspan="2"><code>
+ * getPrefixes(namespaceURI)</code>
+ * return value for specified Namespace URIs</th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr>
+ * <th>Namespace URI parameter</th>
+ * <th>prefixes value returned</th>
+ * </tr>
+ * <tr>
+ * <td>bound Namespace URI, including the <default Namespace URI></td>
+ * <td><code>Iterator</code> over prefixes bound to Namespace URI in the
+ * current scope in an arbitrary, implementation dependent, order</td>
+ * </tr>
+ * <tr>
+ * <td>unbound Namespace URI</td>
+ * <td>empty <code>Iterator</code></td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XML_NS_URI</code>
+ * ("http://www.w3.org/XML/1998/namespace")</td>
+ * <td><code>Iterator</code> with one element set to
+ * <code>XMLConstants.XML_NS_PREFIX</code> ("xml")</td>
+ * </tr>
+ * <tr>
+ * <td><code>XMLConstants.XMLNS_ATTRIBUTE_NS_URI</code>
+ * ("http://www.w3.org/2000/xmlns/")</td>
+ * <td><code>Iterator</code> with one element set to
+ * <code>XMLConstants.XMLNS_ATTRIBUTE</code> ("xmlns")</td>
+ * </tr>
+ * <tr>
+ * <td><code>""</code> or <code>null</code></td>
+ * <td><code>IllegalArgumentException</code> is thrown</td>
+ * </tr>
+ * </tbody> </table>
+ *
+ * @param namespaceURI
+ * URI of Namespace to lookup
+ * @return <code>Iterator</code> for all prefixes bound to the Namespace
+ * URI in the current scope
+ */
+ public Iterator getPrefixes(String namespaceURI) {
+ // TODO : Need to be done
+ return null;
+ }
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXNamespaceContext.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java?view=auto&rev=545991
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java (added)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java Sun Jun 10 19:34:52 2007
@@ -0,0 +1,951 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.stax;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.Location;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.xerces.parsers.XML11Configuration;
+import org.apache.xerces.xni.parser.XMLInputSource;
+import org.apache.xerces.xni.XMLAttributes;
+import org.apache.xerces.util.XMLSymbols;
+
+/**
+ * @author Wei Duan
+ *
+ * @version $Id$
+ */
+public class StAXParser implements XMLStreamReader {
+
+ // The XMLInputFactory instance which creates the StAXParser
+ private XMLInputFactory inputFactory;
+
+ // XML configuration for StAXParser
+ private XML11Configuration configuration;
+
+ // XNI-based internal parser for StAXParser
+ private AbstractStAXParser staxParser;
+
+ // The current stax event type
+ private int curStAXEventType;
+
+ // The stax namespace context
+ private StAXNamespaceContext namespaceContext = null;
+
+ // The stax location
+ private StAXLocation location = null;
+
+ /**
+ * The constructor for StAXParser
+ *
+ * @param inputSource
+ * @param inputFactory
+ */
+ public StAXParser(XMLInputSource inputSource, XMLInputFactory inputFactory)
+ throws XMLStreamException {
+ try {
+ this.inputFactory = inputFactory;
+ this.configuration = new XML11Configuration();
+
+ configuration.setInputSource(inputSource);
+ staxParser = new AbstractStAXParser(configuration);
+ } catch (Exception e) {
+ throw new XMLStreamException("Fail to create StAXParser instance");
+ }
+ }
+
+ /**
+ * Get the value of a feature/property from the underlying implementation
+ *
+ * @param name
+ * The name of the property, may not be null
+ * @return The value of the property
+ * @throws IllegalArgumentException
+ * if name is null
+ */
+ public Object getProperty(java.lang.String name)
+ throws java.lang.IllegalArgumentException {
+ if (name == null) {
+ throw new IllegalArgumentException(
+ "The feature name should not be null");
+ }
+
+ return inputFactory.getProperty(name);
+ }
+
+ /**
+ * Returns true if there are more parsing events and false if there are no
+ * more events. This method will return false if the current state of the
+ * XMLStreamReader is END_DOCUMENT
+ *
+ * @return true if there are more events, false otherwise
+ * @throws XMLStreamException
+ * if there is a fatal error detecting the next state
+ */
+ public boolean hasNext() throws XMLStreamException {
+ boolean hasNext = true;
+ if (curStAXEventType == XMLStreamConstants.END_DOCUMENT) {
+ hasNext = false;
+ }
+
+ return hasNext;
+ }
+
+ /**
+ * Get next parsing event - a processor may return all contiguous character
+ * data in a single chunk, or it may split it into several chunks. If the
+ * property javax.xml.stream.isCoalescing is set to true element content
+ * must be coalesced and only one CHARACTERS event must be returned for
+ * contiguous element content or CDATA Sections. By default entity
+ * references must be expanded and reported transparently to the
+ * application. An exception will be thrown if an entity reference cannot be
+ * expanded. If element content is empty (i.e. content is "") then no
+ * CHARACTERS event will be reported.
+ *
+ * @return the integer code corresponding to the current parse event
+ * @throws java.lang.IllegalStateException -
+ * if this is called when hasNext() returns false
+ * @throws XMLStreamException
+ * if there is an error processing the underlying XML source
+ */
+ public int next() throws XMLStreamException {
+ try {
+ configuration.parse(false);
+ } catch (Exception e) {
+ throw new XMLStreamException(
+ "Error occurs when processing the underlying XML source", e);
+ }
+ if (!hasNext()) {
+ throw new IllegalStateException("No more document to parse");
+ }
+
+ curStAXEventType = staxParser.eventType;
+
+ if (curStAXEventType == XMLStreamConstants.START_DOCUMENT) {
+ this.namespaceContext = new StAXNamespaceContext(
+ staxParser.namespaceContext);
+ this.location = new StAXLocation(staxParser.locator);
+ }
+
+ return curStAXEventType;
+ }
+
+ /**
+ * Test if the current event is of the given type and if the namespace and
+ * name match the current namespace and name of the current event. If the
+ * namespaceURI is null it is not checked for equality, if the localName is
+ * null it is not checked for equality.
+ *
+ * @param type
+ * the event type
+ * @param namespaceURI
+ * the uri of the event, may be null
+ * @param localName
+ * the localName of the event, may be null
+ * @throws XMLStreamException
+ * if the required values are not matched.
+ */
+ public void require(int type, String namespaceURI, String localName)
+ throws XMLStreamException {
+ // Need to be realized
+ }
+
+ /**
+ * Reads the content of a text-only element, an exception is thrown if this
+ * is not a text-only element. Regardless of value of
+ * javax.xml.stream.isCoalescing this method always returns coalesced
+ * content.
+ *
+ * <br />
+ * Precondition: the current event is START_ELEMENT. <br />
+ * Postcondition: the current event is the corresponding END_ELEMENT.
+ *
+ * @throws XMLStreamException
+ * if the current event is not a START_ELEMENT or if a non text
+ * element is encountered
+ */
+ public String getElementText() throws XMLStreamException {
+ if (getEventType() != XMLStreamConstants.START_ELEMENT) {
+ throw new XMLStreamException(
+ "parser must be on START_ELEMENT to read next text",
+ getLocation());
+ }
+ int eventType = next();
+ StringBuffer buf = new StringBuffer();
+ while (eventType != XMLStreamConstants.END_ELEMENT) {
+ if (eventType == XMLStreamConstants.CHARACTERS
+ || eventType == XMLStreamConstants.CDATA
+ || eventType == XMLStreamConstants.SPACE
+ || eventType == XMLStreamConstants.ENTITY_REFERENCE) {
+ buf.append(getText());
+ } else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+ || eventType == XMLStreamConstants.COMMENT) {
+ // skipping
+ } else if (eventType == XMLStreamConstants.END_DOCUMENT) {
+ throw new XMLStreamException(
+ "unexpected end of document when reading element text content",
+ getLocation());
+ } else if (eventType == XMLStreamConstants.START_ELEMENT) {
+ throw new XMLStreamException(
+ "element text content may not contain START_ELEMENT",
+ getLocation());
+ } else {
+ throw new XMLStreamException("Unexpected event type "
+ + eventType, getLocation());
+ }
+ eventType = next();
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Skips any white space (isWhiteSpace() returns true), COMMENT, or
+ * PROCESSING_INSTRUCTION, until a START_ELEMENT or END_ELEMENT is reached.
+ * If other than white space characters, COMMENT, PROCESSING_INSTRUCTION,
+ * START_ELEMENT, END_ELEMENT are encountered, an exception is thrown.
+ * return eventType;
+ *
+ * </pre>
+ *
+ * @return the event type of the element read (START_ELEMENT or END_ELEMENT)
+ * @throws XMLStreamException
+ * if the current event is not white space,
+ * PROCESSING_INSTRUCTION, START_ELEMENT or END_ELEMENT
+ * @throws NoSuchElementException
+ * if this is called when hasNext() returns false
+ */
+ public int nextTag() throws XMLStreamException {
+ int eventType = next();
+ while ((eventType == XMLStreamConstants.CHARACTERS && isWhiteSpace()) // skip
+ // //
+ // //
+ // //
+ // whitespace
+ || (eventType == XMLStreamConstants.CDATA && isWhiteSpace())
+ // skip whitespace
+ || eventType == XMLStreamConstants.SPACE
+ || eventType == XMLStreamConstants.PROCESSING_INSTRUCTION
+ || eventType == XMLStreamConstants.COMMENT) {
+ eventType = next();
+ }
+ if (eventType != XMLStreamConstants.START_ELEMENT
+ && eventType != XMLStreamConstants.END_ELEMENT) {
+ throw new XMLStreamException("expected start or end tag",
+ getLocation());
+ }
+ return eventType;
+ }
+
+ /**
+ * Frees any resources associated with this Reader. This method does not
+ * close the underlying input source.
+ *
+ * @throws XMLStreamException
+ * if there are errors freeing associated resources
+ */
+ public void close() throws XMLStreamException {
+ }
+
+ /**
+ * Return the uri for the given prefix. The uri returned depends on the
+ * current state of the processor.
+ *
+ *
+ * @param prefix
+ * The prefix to lookup, may not be null
+ * @return the uri bound to the given prefix or null if it is not bound
+ * @throws IllegalArgumentException
+ * if the prefix is null
+ */
+ public String getNamespaceURI(String prefix) {
+ if (prefix == null) {
+ throw new IllegalStateException("The prefix can't be null");
+ }
+ return namespaceContext.getNamespaceURI(prefix);
+ }
+
+ /**
+ * Returns true if the cursor points to a start tag (otherwise false)
+ *
+ * @return true if the cursor points to a start tag, false otherwise
+ */
+ public boolean isStartElement() {
+ return curStAXEventType == XMLStreamConstants.START_ELEMENT;
+ }
+
+ /**
+ * Returns true if the cursor points to an end tag (otherwise false)
+ *
+ * @return true if the cursor points to an end tag, false otherwise
+ */
+ public boolean isEndElement() {
+ return curStAXEventType == XMLStreamConstants.END_ELEMENT;
+ }
+
+ /**
+ * Returns true if the cursor points to a character data event
+ *
+ * @return true if the cursor points to character data, false otherwise
+ */
+ public boolean isCharacters() {
+ // TODO: Confirm the whitespace belongs to characters
+ return curStAXEventType == XMLStreamConstants.CHARACTERS;
+ }
+
+ /**
+ * Returns true if the cursor points to a character data event that consists
+ * of all whitespace
+ *
+ * @return true if the cursor points to all whitespace, false otherwise
+ */
+ public boolean isWhiteSpace() {
+ return curStAXEventType == XMLStreamConstants.SPACE;
+ }
+
+ /**
+ * Returns the normalized attribute value of the attribute with the
+ * namespace and localName If the namespaceURI is null the namespace is not
+ * checked for equality
+ *
+ * @param namespaceURI
+ * the namespace of the attribute
+ * @param localName
+ * the local name of the attribute, cannot be null
+ * @return returns the value of the attribute , returns null if not found
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributeValue(String namespaceURI, String localName) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ if (localName == null) {
+ throw new IllegalStateException("Local name can't be null");
+ }
+ XMLAttributes attrs = staxParser.elementAttr;
+ return attrs.getValue(namespaceURI, localName);
+ }
+
+ throw new IllegalStateException(
+ "Current stax event type is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the count of attributes on this START_ELEMENT, this method is
+ * only valid on a START_ELEMENT or ATTRIBUTE. For SAXSource, there is no
+ * explict Attribute event
+ *
+ * @return returns the number of attributes
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public int getAttributeCount() {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getLength();
+ }
+
+ throw new IllegalStateException(
+ "Current event type is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the qname of the attribute at the provided index This method
+ * excludes namespace definitions
+ *
+ * @param index
+ * the position of the attribute
+ * @return the QName of the attribute
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public QName getAttributeName(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ String uri = this.getAttributeNamespace(index);
+ String local = this.getAttributeLocalName(index);
+
+ return new QName(uri, local);
+ }
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the namespace of the attribute at the provided index
+ *
+ * @param index
+ * the position of the attribute
+ * @return the namespace URI (can be null)
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributeNamespace(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getURI(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the localName of the attribute at the provided index
+ *
+ * @param index
+ * the position of the attribute
+ * @return the localName of the attribute
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributeLocalName(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getLocalName(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the prefix of this attribute at the provided index
+ *
+ * @param index
+ * the position of the attribute
+ * @return the prefix of the attribute
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributePrefix(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getPrefix(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the XML type of the attribute at the provided index
+ *
+ * @param index
+ * the position of the attribute
+ * @return the XML type of the attribute
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributeType(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getType(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the value of the attribute at the index
+ *
+ * @param index
+ * the position of the attribute
+ * @return the attribute value
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public String getAttributeValue(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.getValue(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns a boolean which indicates if this attribute was created by
+ * default
+ *
+ * @param index
+ * the position of the attribute
+ * @return true if this is a default attribute
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or ATTRIBUTE
+ */
+ public boolean isAttributeSpecified(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT) {
+ return staxParser.elementAttr.isSpecified(index);
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or ATTRIBUTE");
+ }
+
+ /**
+ * Returns the count of namespaces declared on this START_ELEMENT or
+ * END_ELEMENT.
+ *
+ * @return returns the number of namespace declarations on this specific
+ * element
+ * @throws IllegalStateException
+ * if this is not a START_ELEMEN or, END_ELEMENT
+ */
+ public int getNamespaceCount() {
+ int countNamespace = 0;
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ XMLAttributes attrs = staxParser.elementAttr;
+
+ for (int i = 0; i < attrs.getLength(); i++) {
+ if (attrs.getLocalName(i) == XMLSymbols.PREFIX_XMLNS) {
+ // e.g. xmlns="http://www.w3.org/2001/XMLSchema"
+ countNamespace++;
+ } else if (attrs.getPrefix(i) == XMLSymbols.PREFIX_XMLNS) {
+ // e.g. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/wsdl"
+ countNamespace++;
+ }
+ }
+ return countNamespace;
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or END_ELEMENT");
+ }
+
+ /**
+ * Returns the prefix for the namespace declared at the index. Returns null
+ * if this is the default namespace declaration
+ *
+ * @param index
+ * the position of the namespace declaration
+ * @return returns the namespace prefix
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
+ */
+ public String getNamespacePrefix(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ // TODO : Need to be done
+ return null;
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or END_ELEMENT");
+ }
+
+ /**
+ * Returns the uri for the namespace declared at the index.
+ *
+ * @param index
+ * the position of the namespace declaration
+ * @return returns the namespace uri
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT, END_ELEMENT or NAMESPACE
+ */
+ public String getNamespaceURI(int index) {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ // TODO : Need to be done
+ return null;
+ }
+
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT or END_ELEMENT");
+ }
+
+ /**
+ * Returns a read only namespace context for the current position. The
+ * context is transient and only valid until a call to next() changes the
+ * state of the reader.
+ *
+ * @return return a namespace context
+ */
+ public NamespaceContext getNamespaceContext() {
+ return this.namespaceContext;
+ }
+
+ /**
+ * Returns an integer code that indicates the type of the event the cursor
+ * is pointing to.
+ *
+ * @return the current event type
+ */
+ public int getEventType() {
+ return curStAXEventType;
+ }
+
+ /**
+ * Returns the current value of the parse event as a string, this returns
+ * the string value of a CHARACTERS event, returns the value of a COMMENT,
+ * the replacement value for an ENTITY_REFERENCE, the string value of a
+ * CDATA section, the string value for a SPACE event, or the String value of
+ * the internal subset of the DTD. If an ENTITY_REFERENCE has been resolved,
+ * any character data will be reported as CHARACTERS events.
+ *
+ *
+ * @return the current text or null
+ * @throws java.lang.IllegalStateException
+ * if this state is not a valid text state.
+ */
+ public String getText() {
+ String text = null;
+ if (curStAXEventType == XMLStreamConstants.CHARACTERS
+ || curStAXEventType == XMLStreamConstants.SPACE) {
+ text = staxParser.characters.toString();
+ } else if (curStAXEventType == XMLStreamConstants.COMMENT) {
+ text = staxParser.comment.toString();
+ } else {
+ throw new IllegalStateException(
+ "The current state is not a valid text state.");
+ }
+ return text;
+ }
+
+ /**
+ * Returns an array which contains the characters from this event. This
+ * array should be treated as read-only and transient. I.e. the array will
+ * contain the text characters until the XMLStreamReader moves on to the
+ * next event. Attempts to hold onto the character array beyond that time or
+ * modify the contents of the array are breaches of the contract for this
+ * interface.
+ *
+ * @return the current text or an empty array
+ * @throws java.lang.IllegalStateException
+ * if this state is not a valid text state.
+ */
+ public char[] getTextCharacters() {
+ String text = getText();
+
+ return text == null ? new char[] {} : text.toCharArray();
+ }
+
+ /**
+ * Gets the the text associated with a CHARACTERS, SPACE or CDATA event.
+ * Text starting a "sourceStart" is copied into "target" starting at
+ * "targetStart". Up to "length" characters are copied. The number of
+ * characters actually copied is returned.
+ *
+ * XMLStreamException may be thrown if there are any XML errors in the
+ * underlying source. The "targetStart" argument must be greater than or
+ * equal to 0 and less than the length of "target", Length must be greater
+ * than 0 and "targetStart + length" must be less than or equal to length of
+ * "target".
+ *
+ * @param sourceStart
+ * the index of the first character in the source array to copy
+ * @param target
+ * the destination array
+ * @param targetStart
+ * the start offset in the target array
+ * @param length
+ * the number of characters to copy
+ * @return the number of characters actually copied
+ * @throws XMLStreamException
+ * if the underlying XML source is not well-formed
+ * @throws IndexOutOfBoundsException
+ * if targetStart < 0 or > than the length of target
+ * @throws IndexOutOfBoundsException
+ * if length < 0 or targetStart + length > length of target
+ * @throws UnsupportedOperationException
+ * if this method is not supported
+ * @throws NullPointerException
+ * is if target is null
+ */
+ public int getTextCharacters(int sourceStart, char[] target,
+ int targetStart, int length) throws XMLStreamException {
+
+ if (target == null)
+ throw new NullPointerException();
+
+ int targetLen = target.length;
+
+ if (targetStart < 0 || targetStart > targetLen)
+ throw new ArrayIndexOutOfBoundsException(
+ "The start position of target is out of index");
+
+ if (length < 0)
+ throw new ArrayIndexOutOfBoundsException(
+ "The length is out of index");
+
+ int len = getTextLength();
+ if (sourceStart < 0 || sourceStart > len) {
+ throw new ArrayIndexOutOfBoundsException(
+ "The start position of source is out of index");
+ }
+
+ int avail = len - sourceStart;
+
+ if (avail < length) {
+ length = avail;
+ }
+
+ char[] intBuf = getTextCharacters();
+ int intStart = getTextStart();
+ System.arraycopy(intBuf, intStart + sourceStart, target, targetStart,
+ length);
+ return length;
+ }
+
+ /**
+ * Returns the offset into the text character array where the first
+ * character (of this text event) is stored.
+ *
+ * @throws java.lang.IllegalStateException
+ * if this state is not a valid text state.
+ */
+ public int getTextStart() {
+ if (!hasText()) {
+ throw new IllegalStateException(
+ "The current state is not a valid text state.");
+ }
+
+ // TODO: need further investigation
+ return 0;
+ }
+
+ /**
+ * Returns the length of the sequence of characters for this Text event
+ * within the text character array.
+ *
+ * @throws java.lang.IllegalStateException
+ * if this state is not a valid text state.
+ */
+ public int getTextLength() {
+ if (!hasText()) {
+ throw new IllegalStateException(
+ "The current state is not a valid text state.");
+ }
+
+ // TODO: need further investigation with getTextStart
+ int textLen = getText().length();
+ return textLen;
+ }
+
+ /**
+ * Return input encoding if known or null if unknown.
+ *
+ * @return the encoding of this instance or null
+ */
+ public String getEncoding() {
+ return staxParser.encodingDoc;
+ }
+
+ /**
+ * Return true if the current event has text, false otherwise The following
+ * events have text: CHARACTERS,DTD ,ENTITY_REFERENCE, COMMENT, SPACE
+ *
+ */
+ public boolean hasText() {
+ boolean hasText = false;
+ if (curStAXEventType == XMLStreamConstants.CHARACTERS
+ || curStAXEventType == XMLStreamConstants.ENTITY_REFERENCE
+ || curStAXEventType == XMLStreamConstants.COMMENT
+ || curStAXEventType == XMLStreamConstants.SPACE
+ || curStAXEventType == XMLStreamConstants.DTD) {
+ hasText = true;
+ }
+
+ return hasText;
+ }
+
+ /**
+ * Return the current location of the processor. If the Location is unknown
+ * the processor should return an implementation of Location that returns -1
+ * for the location and null for the publicId and systemId. The location
+ * information is only valid until next() is called.
+ */
+ public Location getLocation() {
+ return this.location;
+ }
+
+ /**
+ * Returns a QName for the current START_ELEMENT or END_ELEMENT event
+ *
+ *
+ * @return the QName for the current START_ELEMENT or END_ELEMENT event
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or END_ELEMENT
+ */
+ public QName getName() {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ return new QName(staxParser.elementName.uri,
+ staxParser.elementName.localpart);
+ }
+ throw new IllegalStateException(
+ "The current state is not a valid START_ELEMENT or END_ELEMENT state.");
+ }
+
+ /**
+ * Returns the (local) name of the current event. For START_ELEMENT or
+ * END_ELEMENT returns the (local) name of the current element. For
+ * ENTITY_REFERENCE it returns entity name.
+ *
+ * The current event must be START_ELEMENT or END_ELEMENT, or
+ * ENTITY_REFERENCE
+ *
+ * @return the localName
+ * @throws IllegalStateException
+ * if this not a START_ELEMENT, END_ELEMENT or ENTITY_REFERENCE
+ */
+ public String getLocalName() {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ return staxParser.elementName.localpart;
+ } else if (curStAXEventType == XMLStreamConstants.ENTITY_REFERENCE) {
+ // TODO
+ return "";
+ } else {
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT, END_ELEMENT or ENTITY_REFERENCE");
+ }
+ }
+
+ /**
+ * returns true if the current event has a name (is a START_ELEMENT or
+ * END_ELEMENT) returns false otherwise
+ */
+ public boolean hasName() {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * If the current event is a START_ELEMENT or END_ELEMENT this method
+ * returns the URI of the current element (URI mapping to the prefix
+ * element/attribute has, if any; or if no prefix, null for attribute, and
+ * the default namespace URI for the element).
+ *
+ * @return the URI bound to this elements prefix, the default namespace, or
+ * null
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT, END_ELEMENT or ATTRIBUTE
+ */
+ public String getNamespaceURI() {
+ // TODO: Investigate whether ATTRIBUTE is existed?
+
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ return staxParser.elementName.uri;
+ } else {
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT, END_ELEMENT");
+ }
+ }
+
+ /**
+ * Returns the prefix of the current event or null if the event does not
+ * have a prefix
+ *
+ * @return the prefix or null
+ * @throws IllegalStateException
+ * if this is not a START_ELEMENT or END_ELEMENT
+ */
+ public String getPrefix() {
+ if (curStAXEventType == XMLStreamConstants.START_ELEMENT
+ || curStAXEventType == XMLStreamConstants.END_ELEMENT) {
+ return staxParser.elementName.prefix;
+ } else {
+ throw new IllegalStateException(
+ "Current state is not START_ELEMENT, END_ELEMENT");
+ }
+ }
+
+ /**
+ * Get the xml version declared on the xml declaration Returns null if none
+ * was declared
+ *
+ * @return the XML version or null
+ */
+ public String getVersion() {
+ return staxParser.versionXML;
+ }
+
+ /**
+ * Get the standalone declaration from the xml declaration.
+ *
+ * @return true if this is standalone, or false otherwise
+ */
+ public boolean isStandalone() {
+ if (standaloneSet()) {
+ if (staxParser.standaloneXML.equalsIgnoreCase("yes")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Checks if standalone was set in the document
+ *
+ * @return true if standalone was set in the document, or false otherwise
+ */
+ public boolean standaloneSet() {
+ return staxParser.standaloneXML == null ? false : true;
+ }
+
+ /**
+ * Returns the character encoding declared on the xml declaration Returns
+ * null if none was declared
+ *
+ * @return the encoding declared in the document or null
+ */
+ public String getCharacterEncodingScheme() {
+ return staxParser.encodingXML;
+ }
+
+ /**
+ * Get the target of a processing instruction
+ *
+ * @return the target
+ * @throws IllegalStateException
+ * if the current event is not a
+ * {@link XMLStreamConstants#PROCESSING_INSTRUCTION}
+ */
+ public String getPITarget() {
+ if (curStAXEventType == XMLStreamConstants.PROCESSING_INSTRUCTION) {
+ return staxParser.piTarget;
+ }
+
+ throw new IllegalStateException(
+ "Current state is not PROCESSING_INSTRUCTION");
+ }
+
+ /**
+ * Get the data section of a processing instruction
+ *
+ * @return the data (if processing instruction has any), or null if the
+ * processing instruction only has target.
+ * @throws IllegalStateException
+ * if the current event is not a
+ * {@link XMLStreamConstants#PROCESSING_INSTRUCTION}
+ */
+ public String getPIData() {
+ if (curStAXEventType == XMLStreamConstants.PROCESSING_INSTRUCTION) {
+ return staxParser.piData.toString();
+ }
+
+ throw new IllegalStateException(
+ "Current state is not PROCESSING_INSTRUCTION");
+ }
+
+}
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/StAXParser.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java?view=diff&rev=545991&r1=545990&r2=545991
==============================================================================
--- xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java (original)
+++ xerces/java/branches/stax-dev/src/org/apache/xerces/stax/XMLInputFactoryImpl.java Sun Jun 10 19:34:52 2007
@@ -33,6 +33,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import org.apache.xerces.xni.parser.XMLInputSource;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -41,6 +42,7 @@
* <p>Implementation of XMLInputFactory.</p>
*
* @author Hua Lei
+ * @author Wei Duan
*
* @version $Id$
*/
@@ -83,7 +85,10 @@
public XMLStreamReader createXMLStreamReader(InputStream stream)
throws XMLStreamException {
- return null;
+ XMLInputSource inputsource = new XMLInputSource(null, null, null,
+ stream, null);
+ StAXParser xmlStreamReader = new StAXParser(inputsource, this);
+ return xmlStreamReader;
}
public XMLStreamReader createXMLStreamReader(InputStream stream,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org