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 2010/08/05 19:54:36 UTC

svn commit: r982714 - in /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti: AttrImpl.java SchemaDOM.java SchemaDOMImplementation.java

Author: mrglavas
Date: Thu Aug  5 17:54:35 2010
New Revision: 982714

URL: http://svn.apache.org/viewvc?rev=982714&view=rev
Log:
Minor enhancements to the Schema DOM to allow nodes from it to be imported into Xerces' other DOM implementations. I expect this will be useful in the work that Udayanga has been doing for xs:override.

Added:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java   (with props)
Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/AttrImpl.java
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/AttrImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/AttrImpl.java?rev=982714&r1=982713&r2=982714&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/AttrImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/AttrImpl.java Thu Aug  5 17:54:35 2010
@@ -19,6 +19,7 @@ package org.apache.xerces.impl.xs.opti;
 
 import org.w3c.dom.Attr;
 import org.w3c.dom.DOMException;
+import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.TypeInfo;
@@ -80,6 +81,10 @@ public class AttrImpl extends NodeImpl 
         return element;
     }
     
+    public Document getOwnerDocument() {
+        return element.getOwnerDocument();
+    }
+    
     public void setValue(String value) throws DOMException {
         this.value = value;
     }

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java?rev=982714&r1=982713&r2=982714&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java Thu Aug  5 17:54:35 2010
@@ -26,6 +26,7 @@ import org.apache.xerces.xni.QName;
 import org.apache.xerces.xni.XMLAttributes;
 import org.apache.xerces.xni.XMLString;
 import org.w3c.dom.Attr;
+import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Element;
 import org.w3c.dom.NamedNodeMap;
 import org.w3c.dom.Node;
@@ -97,7 +98,7 @@ public class SchemaDOM extends DefaultDo
         // set the attributes
         Attr[] attrs = new Attr[attributes.getLength()];
         for (int i=0; i<attributes.getLength(); i++) {
-            attrs[i] = new AttrImpl(null, 
+            attrs[i] = new AttrImpl(node, 
                     attributes.getPrefix(i), 
                     attributes.getLocalName(i), 
                     attributes.getQName(i), 
@@ -343,6 +344,10 @@ public class SchemaDOM extends DefaultDo
         return (ElementImpl)relations[0][1];
     }
     
+    public DOMImplementation getImplementation() {
+        return SchemaDOMImplementation.getDOMImplementation();
+    }
+    
     // commence the serialization of an annotation
     void startAnnotation(QName elemName, XMLAttributes attributes,
             NamespaceContext namespaceContext) {

Added: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java?rev=982714&view=auto
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java (added)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java Thu Aug  5 17:54:35 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.impl.xs.opti;
+
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+
+/**
+ * @version $Id$
+ */
+final class SchemaDOMImplementation implements DOMImplementation {
+    
+    private static final SchemaDOMImplementation singleton = new SchemaDOMImplementation();
+    
+    /** NON-DOM: Obtain and return the single shared object */
+    public static DOMImplementation getDOMImplementation() {
+        return singleton;
+    }
+    
+    private SchemaDOMImplementation() {}
+
+    public Document createDocument(String namespaceURI, String qualifiedName, DocumentType doctype)
+            throws DOMException {
+        throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
+    }
+
+    public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId)
+            throws DOMException {
+        throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
+    }
+
+    public Object getFeature(String feature, String version) {
+        if (singleton.hasFeature(feature, version)) {
+            return singleton;
+        }
+        return null;
+    }
+
+    public boolean hasFeature(String feature, String version) {
+        final boolean anyVersion = version == null || version.length() == 0;
+        return (feature.equalsIgnoreCase("Core") || feature.equalsIgnoreCase("XML")) && 
+            (anyVersion || version.equals("1.0") || version.equals("2.0") || version.equals("3.0"));
+    }
+
+}

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/opti/SchemaDOMImplementation.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org