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 ru...@apache.org on 2006/06/18 20:33:17 UTC
svn commit: r415168 - in
/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom:
AttrImpl.java ElementImpl.java jaxp/DocumentBuilderFactoryImpl.java
jaxp/DocumentBuilderImpl.java
Author: ruchithf
Date: Sun Jun 18 11:33:17 2006
New Revision: 415168
URL: http://svn.apache.org/viewvc?rev=415168&view=rev
Log:
Changes to DOOM's DOM Level 3 support required to get opensaml working with DOOM :-)
- Implementing setIdAttr* methods in ElementImpl
- Hack for set/getSchema()
Modified:
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/AttrImpl.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java
Modified: webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=415168&r1=415167&r2=415168&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/AttrImpl.java Sun Jun 18 11:33:17 2006
@@ -63,6 +63,11 @@
*/
protected ParentNode parent;
+ /**
+ * Flag used to mark an attribute as per the DOM Level 3 specification
+ */
+ protected boolean isId;
+
protected AttrImpl(DocumentImpl ownerDocument, OMFactory factory) {
super(ownerDocument, factory);
}
@@ -389,8 +394,7 @@
}
public boolean isId() {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
+ return isId;
}
public String toString() {
Modified: webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=415168&r1=415167&r2=415168&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/ElementImpl.java Sun Jun 18 11:33:17 2006
@@ -1206,7 +1206,6 @@
* @see org.w3c.dom.Node#getPrefix()
*/
public String getPrefix() {
- // TODO Error checking
return (this.namespace == null) ? null : this.namespace.getPrefix();
}
@@ -1299,7 +1298,7 @@
// check if the parent of this element has the same namespace
// as the default and if NOT add the attr
- if (this.parentNode.getNamespaceURI() != this.getNamespaceURI()) {
+ if (this.parentNode != null && this.parentNode.getNamespaceURI() != this.getNamespaceURI()) {
AttrImpl attr = new AttrImpl(this.ownerNode, "xmlns",
this.namespace.getName(), this.factory);
attr.setOMNamespace(new NamespaceImpl(
@@ -1364,23 +1363,80 @@
* DOM-Level 3 methods
*/
- public TypeInfo getSchemaTypeInfo() {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
- }
-
- public void setIdAttribute(String arg0, boolean arg1) throws DOMException {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
- }
-
- public void setIdAttributeNode(Attr arg0, boolean arg1) throws DOMException {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
+ public void setIdAttribute(String name, boolean isId) throws DOMException {
+ if (this.isReadonly()) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ //find the attr
+ AttrImpl tempAttr = (AttrImpl)this.getAttributeNode(name);
+ if(tempAttr == null) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ msg);
+ }
+
+ tempAttr.isId = isId;
}
- public void setIdAttributeNS(String arg0, String arg1, boolean arg2)
+ public void setIdAttributeNS(String namespaceURI, String localName, boolean isId)
throws DOMException {
+ if (this.isReadonly()) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ //find the attr
+ AttrImpl tempAttr = (AttrImpl)this.getAttributeNodeNS(namespaceURI, localName);
+ if(tempAttr == null) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ msg);
+ }
+
+ tempAttr.isId = isId;
+ }
+
+ public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException {
+ if (this.isReadonly()) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NO_MODIFICATION_ALLOWED_ERR", null);
+ throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
+ msg);
+ }
+ //find the attr
+ Iterator attrIter = this.getAllAttributes();
+ AttrImpl tempAttr = null;
+ while (attrIter.hasNext()) {
+ AttrImpl attr = (AttrImpl) attrIter.next();
+ if(attr.equals(idAttr)) {
+ tempAttr = attr;
+ break;
+ }
+ }
+
+ if(tempAttr == null) {
+ String msg = DOMMessageFormatter.formatMessage(
+ DOMMessageFormatter.DOM_DOMAIN,
+ "NOT_FOUND_ERR", null);
+ throw new DOMException(DOMException.NOT_FOUND_ERR,
+ msg);
+ }
+
+ tempAttr.isId = isId;
+ }
+
+ public TypeInfo getSchemaTypeInfo() {
// TODO TODO
throw new UnsupportedOperationException("TODO");
}
Modified: webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java?rev=415168&r1=415167&r2=415168&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java Sun Jun 18 11:33:17 2006
@@ -18,6 +18,7 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory {
@@ -30,6 +31,8 @@
private static String originalDocumentBuilderFactoryClassName = null;
private static ThreadLocal documentBuilderFactoryTracker = new ThreadLocal();
+ protected Schema schema;
+
public static boolean isDOOMRequired() {
Object value = documentBuilderFactoryTracker.get();
return (value != null);
@@ -68,7 +71,7 @@
* Determine which DocumentBuilder implementation should be returned
*/
return isDOOMRequired()
- ? new DocumentBuilderImpl()
+ ? new DocumentBuilderImpl(this)
: originalDocumentBuilderFactory.newDocumentBuilder();
}
@@ -87,14 +90,33 @@
return new DocumentBuilderFactoryImpl();
}
- public void setFeature(String arg0, boolean arg1)
+ public void setFeature(String name, boolean value)
throws ParserConfigurationException {
- // TODO TODO
- throw new UnsupportedOperationException("TODO");
+ // TODO TODO OS
}
public boolean getFeature(String arg0) throws ParserConfigurationException {
// TODO TODO
throw new UnsupportedOperationException("TODO");
}
+
+ /* (non-Javadoc)
+ * @see javax.xml.parsers.DocumentBuilderFactory#setSchema(javax.xml.validation.Schema)
+ */
+ public void setSchema(Schema schema) {
+ //HACK: Overriding to get opensaml working !!
+ this.schema = schema;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.xml.parsers.DocumentBuilderFactory#getSchema()
+ */
+ public Schema getSchema() {
+ //HACK: Overriding to get opensaml working !!
+ return this.schema;
+ }
+
+
+
+
}
Modified: webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java?rev=415168&r1=415167&r2=415168&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java Sun Jun 18 11:33:17 2006
@@ -31,6 +31,8 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -38,8 +40,14 @@
public class DocumentBuilderImpl extends DocumentBuilder {
- public DocumentBuilderImpl() {
+ /**
+ * The DocumentBuilderFactory used to create this document builder
+ */
+ private DocumentBuilderFactoryImpl factory;
+
+ protected DocumentBuilderImpl(DocumentBuilderFactoryImpl fac) {
super();
+ this.factory = fac;
}
/**
@@ -81,12 +89,10 @@
public void setEntityResolver(EntityResolver arg0) {
// TODO
- throw new UnsupportedOperationException("TODO");
}
public void setErrorHandler(ErrorHandler arg0) {
- // TODO
- throw new UnsupportedOperationException("TODO");
+ // TODO
}
public Document parse(InputSource inputSource) throws SAXException,
@@ -153,4 +159,14 @@
throw new UnsupportedOperationException("TODO");
}
+ /* (non-Javadoc)
+ * @see javax.xml.parsers.DocumentBuilder#getSchema()
+ */
+ public Schema getSchema() {
+ //HACK : To get opensaml working
+ return this.factory.schema;
+ }
+
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org