You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by ve...@apache.org on 2009/08/08 15:33:56 UTC
svn commit: r802372 -
/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/
Author: veithen
Date: Sat Aug 8 13:33:55 2009
New Revision: 802372
URL: http://svn.apache.org/viewvc?rev=802372&view=rev
Log:
Completed StAX dialect implementation for XLXP (version 1).
Added:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPDialect.java
- copied, changed from r802331, webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/BaseXLXPDialect.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java (with props)
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java (with props)
Removed:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/BaseXLXPDialect.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/CompliantXLXPDialect.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/NonCompliantXLXPDialect.java
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialect.java
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialect.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialect.java?rev=802372&r1=802371&r2=802372&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialect.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialect.java Sat Aug 8 13:33:55 2009
@@ -77,6 +77,18 @@
* However, to improve portability, the dialect implementations normalize these methods to
* throw an {@link IllegalStateException} if they are called in a state other than
* {@link javax.xml.stream.XMLStreamConstants#START_DOCUMENT}.</li>
+ * <li>The documentation of {@link javax.xml.stream.XMLStreamReader#isCharacters()} specifies
+ * that this method "returns true if the cursor points to a character data event".
+ * On the other hand, the documentation of {@link javax.xml.stream.XMLStreamReader}
+ * states that "parsing events are defined as the XML Declaration, a DTD, start tag,
+ * character data, white space, end tag, comment, or processing instruction" and thus
+ * makes a clear distinction between character data events and white space events.
+ * This means that {@link javax.xml.stream.XMLStreamReader#isCharacters()} should return
+ * <code>true</code> if and only if the current event is
+ * {@link javax.xml.stream.XMLStreamConstants#CHARACTERS}. This is the case for most parsers,
+ * but some return <code>true</code> for {@link javax.xml.stream.XMLStreamConstants#SPACE}
+ * events as well. Where necessary, the dialect implementations correct this behavior.
+ * </li>
* </ul>
* <p>
* Note that there are several ambiguities in the StAX specification which are not addressed by
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java?rev=802372&r1=802371&r2=802372&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/StAXDialectDetector.java Sat Aug 8 13:33:55 2009
@@ -235,15 +235,14 @@
// Try IBM's XL XP-J
Class cls = loadClass(classLoader, rootUrl, "com.ibm.xml.xlxp.api.stax.StAXImplConstants");
if (cls != null) {
- boolean isStAXCompliant;
+ boolean isSetPrefixBroken;
try {
cls.getField("IS_SETPREFIX_BEFORE_STARTELEMENT");
- isStAXCompliant = true;
+ isSetPrefixBroken = false;
} catch (NoSuchFieldException ex) {
- isStAXCompliant = false;
+ isSetPrefixBroken = true;
}
- return isStAXCompliant ? CompliantXLXPDialect.INSTANCE
- : NonCompliantXLXPDialect.INSTANCE;
+ return new XLXPDialect(isSetPrefixBroken);
}
return null;
Copied: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPDialect.java (from r802331, webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/BaseXLXPDialect.java)
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPDialect.java?p2=webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPDialect.java&p1=webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/BaseXLXPDialect.java&r1=802331&r2=802372&rev=802372&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/BaseXLXPDialect.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPDialect.java Sat Aug 8 13:33:55 2009
@@ -21,8 +21,21 @@
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+class XLXPDialect extends AbstractStAXDialect {
+ private final boolean isSetPrefixBroken;
+
+ public XLXPDialect(boolean isSetPrefixBroken) {
+ this.isSetPrefixBroken = isSetPrefixBroken;
+ }
+
+ public String getName() {
+ return isSetPrefixBroken ? "XL XP-J (StAX non-compliant versions)"
+ : "XL XP-J (StAX compliant versions)";
+ }
-abstract class BaseXLXPDialect implements StAXDialect {
public void enableCDataReporting(XMLInputFactory factory) {
// TODO: check if that is enough
factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
@@ -38,11 +51,25 @@
return factory;
}
+ public XMLStreamReader normalize(XMLStreamReader reader) {
+ return new XLXPStreamReaderWrapper(reader);
+ }
+
+ public XMLStreamWriter normalize(XMLStreamWriter writer) {
+ XMLStreamWriter wrapper = new XLXPStreamWriterWrapper(writer);
+ // Early versions of XLXP the scope of the prefix bindings defined by setPrefix
+ // is incorrect
+ if (isSetPrefixBroken) {
+ wrapper = new NamespaceContextCorrectingXMLStreamWriterWrapper(wrapper);
+ }
+ return wrapper;
+ }
+
public XMLInputFactory normalize(XMLInputFactory factory) {
- return factory;
+ return new NormalizingXMLInputFactoryWrapper(factory, this);
}
public XMLOutputFactory normalize(XMLOutputFactory factory) {
- return factory;
+ return new NormalizingXMLOutputFactoryWrapper(factory, this);
}
}
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java?rev=802372&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java Sat Aug 8 13:33:55 2009
@@ -0,0 +1,35 @@
+/*
+ * 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.axiom.util.stax.dialect;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper;
+
+class XLXPStreamReaderWrapper extends XMLStreamReaderWrapper {
+ public XLXPStreamReaderWrapper(XMLStreamReader parent) {
+ super(parent);
+ }
+
+ public boolean isCharacters() {
+ // XLXP returns true for SPACE events as well; this is not correct
+ return getEventType() == CHARACTERS;
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamReaderWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java?rev=802372&view=auto
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java (added)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java Sat Aug 8 13:33:55 2009
@@ -0,0 +1,39 @@
+/*
+ * 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.axiom.util.stax.dialect;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.axiom.util.stax.wrapper.XMLStreamWriterWrapper;
+
+class XLXPStreamWriterWrapper extends XMLStreamWriterWrapper {
+ public XLXPStreamWriterWrapper(XMLStreamWriter parent) {
+ super(parent);
+ }
+
+ public void writeStartDocument(String encoding, String version) throws XMLStreamException {
+ if (encoding == null) {
+ throw new IllegalArgumentException();
+ } else {
+ super.writeStartDocument(encoding, version);
+ }
+ }
+}
Propchange: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/util/stax/dialect/XLXPStreamWriterWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native