You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/07/19 22:33:55 UTC
svn commit: r1363529 - in /webservices/axiom/branches/AXIOM-435/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-api/src/main/java/org/apache/axiom/om/impl/builder/
axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/
axiom-impl/...
Author: veithen
Date: Thu Jul 19 20:33:54 2012
New Revision: 1363529
URL: http://svn.apache.org/viewvc?rev=1363529&view=rev
Log:
More unfinished code.
Modified:
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/OMEntityReference.java
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
webservices/axiom/branches/AXIOM-435/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java
webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/OMEntityReference.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/OMEntityReference.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/OMEntityReference.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/OMEntityReference.java Thu Jul 19 20:33:54 2012
@@ -18,8 +18,55 @@
*/
package org.apache.axiom.om;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.EntityReference;
+import org.w3c.dom.Node;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
+
/**
* Represents an unexpanded entity reference in an XML document.
+ * <p>
+ * Different XML APIs and object models handle entity references fairly differently:
+ * <ul>
+ * <li>In DOM, the way entity references in an XML document are processed depends on the setting for
+ * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean) expandEntityReferences}. If this
+ * property is set to <code>true</code> (default), then the parser will expand entity references and
+ * the resulting DOM tree simply contains the nodes resulting from this expansion. If this property
+ * is set to <code>false</code>, then the parser will still expand entity references, but the
+ * resulting DOM tree will contain {@link EntityReference} nodes, the children of which represent
+ * the nodes resulting from this expansion. Note that since an entity declaration may contain
+ * markup, the children of an {@link EntityReference} node may have a type other than
+ * {@link Node#TEXT_NODE}. Application code not interested in entity references will generally set
+ * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean) expandEntityReferences} to
+ * <code>true</code> in order to avoid the additional programming logic required to process
+ * {@link EntityReference} nodes.
+ * <li>In SAX, the parser will always expand entity references and report the events resulting from
+ * this expansion to the {@link ContentHandler}. In addition to that, if a {@link LexicalHandler} is
+ * registered, then the parser will report the start and end of the expansion using
+ * {@link LexicalHandler#startEntity(String)} and {@link LexicalHandler#endEntity(String)}. This
+ * means that the processing of entity references in SAX is similar to DOM with
+ * {@link DocumentBuilderFactory#setExpandEntityReferences(boolean) expandEntityReferences} set to
+ * <code>false</code>. Note that in SAX there is no corresponding configuration property. This makes
+ * sense because an application not interested in entity references can simply ignore the
+ * {@link LexicalHandler#startEntity(String)} and {@link LexicalHandler#endEntity(String)} events or
+ * not register a {@link LexicalHandler} at all.
+ * <li>In StAX, the way entity references are processed depends on the setting for the
+ * {@link XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES} property. If this property is set to true
+ * (default), then the parser will expand entity references and report only the events resulting
+ * from that expansion. If the property is set to false, then the parser no longer expands entity
+ * references. Instead, it will report each entity reference using a single
+ * {@link XMLStreamConstants#ENTITY_REFERENCE} event. {@link XMLStreamReader#getText()} can then be
+ * used to get the replacement value for the entity. Note that this replacement value may contain
+ * unparsed markup. One can see that the way StAX reports entity references is significantly
+ * different than DOM or SAX.
+ * </ul>
+ * Axiom models entity references in the same way as StAX: the node corresponding to an (unexpanded)
+ * entity reference only stores the name of the entity as well as the replacement value.
*/
public interface OMEntityReference extends OMNode {
/**
@@ -28,4 +75,12 @@ public interface OMEntityReference exten
* @return the name of the entity
*/
String getName();
+
+ /**
+ * Get the replacement value for this entity reference. Note that the replacement value is a
+ * simple string and may therefore contain unparsed markup.
+ *
+ * @return the replacement value, or <code>null</code> if the replacement value is not available
+ */
+ String getReplacementText();
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/OMFactoryEx.java Thu Jul 19 20:33:54 2012
@@ -57,7 +57,7 @@ public interface OMFactoryEx extends OMF
OMProcessingInstruction createOMProcessingInstruction(OMContainer parent,
String piTarget, String piData, boolean fromBuilder);
- OMEntityReference createOMEntityReference(OMContainer parent, String name, boolean fromBuilder);
+ OMEntityReference createOMEntityReference(OMContainer parent, String name, String replacementText, boolean fromBuilder);
OMNode importNode(OMNode child);
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/SAXOMBuilder.java Thu Jul 19 20:33:54 2012
@@ -247,7 +247,7 @@ public class SAXOMBuilder extends Defaul
public void startEntity(String name) throws SAXException {
if (!expandEntityReferences) {
- addNode(factory.createOMEntityReference(getContainer(), name, true));
+ addNode(factory.createOMEntityReference(getContainer(), name, null, true));
inEntityReference = true;
}
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/builder/StAXOMBuilder.java Thu Jul 19 20:33:54 2012
@@ -495,7 +495,7 @@ public class StAXOMBuilder extends StAXB
}
protected OMNode createEntityReference() {
- return omfactory.createOMEntityReference(target, parser.getLocalName(), true);
+ return omfactory.createOMEntityReference(target, parser.getLocalName(), parser.getText(), true);
}
protected void endElement() {
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/SwitchingWrapper.java Thu Jul 19 20:33:54 2012
@@ -409,6 +409,8 @@ class SwitchingWrapper extends AbstractX
return ((OMComment)lastNode).getValue();
case DTD:
return ((OMDocType)lastNode).getValue();
+ case ENTITY_REFERENCE:
+ return ((OMEntityReference)lastNode).getReplacementText();
default:
throw new IllegalStateException();
}
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMEntityReferenceImpl.java Thu Jul 19 20:33:54 2012
@@ -29,10 +29,13 @@ import org.apache.axiom.om.OMNode;
public class OMEntityReferenceImpl extends OMLeafNode implements OMEntityReference {
private final String name;
+ private final String replacementText;
- public OMEntityReferenceImpl(OMContainer parent, String name, OMFactory factory, boolean fromBuilder) {
+ public OMEntityReferenceImpl(OMContainer parent, String name, String replacementText,
+ OMFactory factory, boolean fromBuilder) {
super(parent, factory, fromBuilder);
this.name = name;
+ this.replacementText = replacementText;
}
public int getType() {
@@ -47,6 +50,10 @@ public class OMEntityReferenceImpl exten
return name;
}
+ public String getReplacementText() {
+ return replacementText;
+ }
+
OMNode clone(OMCloneOptions options, OMContainer targetParent) {
// TODO
throw new UnsupportedOperationException();
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/PushOMBuilder.java Thu Jul 19 20:33:54 2012
@@ -180,7 +180,7 @@ public class PushOMBuilder extends Abstr
}
protected void doWriteEntityRef(String name) throws XMLStreamException {
- factory.createOMEntityReference(parent, name, true);
+ factory.createOMEntityReference(parent, name, null, true);
}
protected void doWriteProcessingInstruction(String target, String data) {
Modified: webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java?rev=1363529&r1=1363528&r2=1363529&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java (original)
+++ webservices/axiom/branches/AXIOM-435/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/factory/OMLinkedListImplFactory.java Thu Jul 19 20:33:54 2012
@@ -358,8 +358,8 @@ public class OMLinkedListImplFactory imp
return new OMDocumentImpl(builder, this);
}
- public OMEntityReference createOMEntityReference(OMContainer parent, String name, boolean fromBuilder) {
- return new OMEntityReferenceImpl(parent, name, this, fromBuilder);
+ public OMEntityReference createOMEntityReference(OMContainer parent, String name, String replacementText, boolean fromBuilder) {
+ return new OMEntityReferenceImpl(parent, name, replacementText, this, fromBuilder);
}
/**