You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by sa...@apache.org on 2002/07/17 22:07:37 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/dom PSVIAttrNSImpl.java PSVIDOMImplementationImpl.java PSVIDocumentImpl.java PSVIElementNSImpl.java DOMImplementationSourceImpl.java

sandygao    2002/07/17 13:07:36

  Modified:    java/src/org/apache/xerces/dom
                        DOMImplementationSourceImpl.java
  Added:       java/src/org/apache/xerces/dom PSVIAttrNSImpl.java
                        PSVIDOMImplementationImpl.java
                        PSVIDocumentImpl.java PSVIElementNSImpl.java
  Log:
  Add a new kind of DOM document implmentation, which supports PSVI.
  When this kind of document is used, element/attribute nodes can be casted
  to Element/AttributePSVI interfaces to retrieve PSVI properties.
  
  Revision  Changes    Path
  1.4       +5 -0      xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java
  
  Index: DOMImplementationSourceImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationSourceImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMImplementationSourceImpl.java	12 Jun 2002 00:27:46 -0000	1.3
  +++ DOMImplementationSourceImpl.java	17 Jul 2002 20:07:36 -0000	1.4
  @@ -97,6 +97,11 @@
           if (testImpl(impl, features)) {
               return impl;
           }
  +        // if not try the PSVIDOMImplementation
  +        impl = PSVIDOMImplementationImpl.getDOMImplementation();
  +        if (testImpl(impl, features)) {
  +            return impl;
  +        }
           return null;
       }
   
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/dom/PSVIAttrNSImpl.java
  
  Index: PSVIAttrNSImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.dom;
  
  import org.apache.xerces.xni.psvi.AttributePSVI;
  import org.apache.xerces.impl.xs.psvi.*;
  
  /**
   * Attribute namespace implementation; stores PSVI attribute items.
   * 
   * @author Sandy Gao, IBM
   * 
   * @version $Id: PSVIAttrNSImpl.java,v 1.1 2002/07/17 20:07:36 sandygao Exp $
   */
  public class PSVIAttrNSImpl extends AttrNSImpl implements AttributePSVI {
  
      /**
       * Construct an attribute node.
       */
      public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 
                            String qualifiedName, String localName) {
          super(ownerDocument, namespaceURI, qualifiedName, localName);
      }
      
      /**
       * Construct an attribute node.
       */
      public PSVIAttrNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 
                            String qualifiedName) {
          super(ownerDocument, namespaceURI, qualifiedName);
      }
      
      /** attribute declaration */
      protected XSAttributeDeclaration fDeclaration = null;
  
      /** type of attribute, simpleType */
      protected XSTypeDefinition fTypeDecl = null;
  
      /** If this attribute was explicitly given a 
       * value in the original document, this is true; otherwise, it is false  */
      protected boolean fSpecified = true;
  
      /** schema normalized value property */
      protected String fNormalizedValue = null;
  
      /** member type definition against which attribute was validated */
      protected XSSimpleTypeDefinition fMemberType = null;
  
      /** validation attempted: none, partial, full */
      protected short fValidationAttempted = AttributePSVI.VALIDATION_NONE;
  
      /** validity: valid, invalid, unknown */
      protected short fValidity = AttributePSVI.VALIDITY_UNKNOWN;
  
      /** error codes */
      protected StringList fErrorCodes = null;
  
      /** validation context: could be QName or XPath expression*/
      protected String fValidationContext = null;
  
      //
      // AttributePSVI methods
      //
  
      /**
       * [schema default]
       *
       * @return The canonical lexical representation of the declaration's {value constraint} value.
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
       */
      public String getSchemaDefault() {
          return fDeclaration == null ? null : fDeclaration.getConstraintValue();
      }
  
      /**
       * [schema normalized value]
       *
       *
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
       * @return the normalized value of this item after validation
       */
      public String getSchemaNormalizedValue() {
          return fNormalizedValue;
      }
  
      /**
       * [schema specified] 
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
       * @return false value was specified in schema, true value comes from the infoset
       */
      public boolean getIsSchemaSpecified() {
          return fSpecified;
      }
  
  
      /**
       * Determines the extent to which the document has been validated
       *
       * @return return the [validation attempted] property. The possible values are
       *         NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
       */
      public short getValidationAttempted() {
          return fValidationAttempted;
      }
  
      /**
       * Determine the validity of the node with respect
       * to the validation being attempted
       *
       * @return return the [validity] property. Possible values are:
       *         UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
       */
      public short getValidity() {
          return fValidity;
      }
  
      /**
       * A list of error codes generated from validation attempts.
       * Need to find all the possible subclause reports that need reporting
       *
       * @return list of error codes
       */
      public StringList getErrorCodes() {
          return fErrorCodes;
      }
  
      // This is the only information we can provide in a pipeline.
      public String getValidationContext() {
          return fValidationContext;
      }
  
      /**
       * An item isomorphic to the type definition used to validate this element.
       * 
       * @return  a type declaration
       */
      public XSTypeDefinition getTypeDefinition() {
          return fTypeDecl;
      }
  
      /**
       * If and only if that type definition is a simple type definition
       * with {variety} union, or a complex type definition whose {content type}
       * is a simple thype definition with {variety} union, then an item isomorphic
       * to that member of the union's {member type definitions} which actually
       * validated the element item's normalized value.
       * 
       * @return  a simple type declaration
       */
      public XSSimpleTypeDefinition getMemberTypeDefinition() {
          return fMemberType;
      }
  
      /**
       * An item isomorphic to the attribute declaration used to validate
       * this attribute.
       * 
       * @return  an attribute declaration
       */
      public XSAttributeDeclaration getAttributeDeclaration() {
          return fDeclaration;
      }
  
      /**
       * Copy PSVI properties from another psvi item.
       * 
       * @param attr  the source of attribute PSVI items
       */
      public void setPSVI(AttributePSVI attr) {
          this.fDeclaration = attr.getAttributeDeclaration();
          this.fValidationContext = attr.getValidationContext();
          this.fValidity = attr.getValidity();
          this.fValidationAttempted = attr.getValidationAttempted();
          this.fErrorCodes = attr.getErrorCodes();
          this.fNormalizedValue = attr.getSchemaNormalizedValue();
          this.fTypeDecl = attr.getTypeDefinition();
          this.fMemberType = attr.getMemberTypeDefinition();
          this.fSpecified = attr.getIsSchemaSpecified();
      }
      
  }
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java
  
  Index: PSVIDOMImplementationImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.dom;
  
  import org.w3c.dom.DOMException;
  import org.w3c.dom.DOMImplementation;
  import org.w3c.dom.Document;
  import org.w3c.dom.DocumentType;
  import org.w3c.dom.Element;
  
  /**
   * The DOMImplementation class is description of a particular
   * implementation of the Document Object Model. As such its data is
   * static, shared by all instances of this implementation.
   * <P>
   * The DOM API requires that it be a real object rather than static
   * methods. However, there's nothing that says it can't be a singleton,
   * so that's how I've implemented it.
   *
   * @version $Id: PSVIDOMImplementationImpl.java,v 1.1 2002/07/17 20:07:36 sandygao Exp $
   * @since  PR-DOM-Level-1-19980818.
   */
  public class PSVIDOMImplementationImpl extends CoreDOMImplementationImpl {
  
      //
      // Data
      //
  
      // static
  
      /** Dom implementation singleton. */
      static PSVIDOMImplementationImpl singleton = new PSVIDOMImplementationImpl();
  
      //
      // Public methods
      //
  
      /** NON-DOM: Obtain and return the single shared object */
      public static DOMImplementation getDOMImplementation() {
          return singleton;
      }  
  
      //
      // DOMImplementation methods
      //
  
      /** 
       * Test if the DOM implementation supports a specific "feature" --
       * currently meaning language and level thereof.
       * 
       * @param feature      The package name of the feature to test.
       * In Level 1, supported values are "HTML" and "XML" (case-insensitive).
       * At this writing, org.apache.xerces.dom supports only XML.
       *
       * @param version      The version number of the feature being tested.
       * This is interpreted as "Version of the DOM API supported for the
       * specified Feature", and in Level 1 should be "1.0"
       *
       * @returns    true iff this implementation is compatable with the
       * specified feature and version.
       */
      public boolean hasFeature(String feature, String version) {
          return super.hasFeature(feature, version) ||
                 feature.equalsIgnoreCase("PSVI");
      } // hasFeature(String,String):boolean
      
      /**
       * Introduced in DOM Level 2. <p>
       * 
       * Creates an XML Document object of the specified type with its document
       * element.
       *
       * @param namespaceURI     The namespace URI of the document
       *                         element to create, or null. 
       * @param qualifiedName    The qualified name of the document
       *                         element to create. 
       * @param doctype          The type of document to be created or null.<p>
       *
       *                         When doctype is not null, its
       *                         Node.ownerDocument attribute is set to
       *                         the document being created.
       * @return Document        A new Document object.
       * @throws DOMException    WRONG_DOCUMENT_ERR: Raised if doctype has
       *                         already been used with a different document.
       * @since WD-DOM-Level-2-19990923
       */
      public Document           createDocument(String namespaceURI, 
                                               String qualifiedName, 
                                               DocumentType doctype)
                                               throws DOMException
      {
      	if (doctype != null && doctype.getOwnerDocument() != null) {
              throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
                                     "DOM005 Wrong document");
          }
          DocumentImpl doc = new PSVIDocumentImpl(doctype);
          Element e = doc.createElementNS( namespaceURI, qualifiedName);
          doc.appendChild(e);
          return doc;
      }
      
  
  } // class DOMImplementationImpl
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/dom/PSVIDocumentImpl.java
  
  Index: PSVIDocumentImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.dom;
  
  // REVISIT: This is a HACK! DO NOT MODIFY THIS import.
  //          It allows us to expose DOM L3 implemenation via org.w3c.dom packages
  import org.w3c.dom.*;
  
  /**
   * Our own document implementation, which knows how to create an element
   * with PSVI information.
   * 
   * @author Sandy Gao, IBM
   * 
   * @version $Id: PSVIDocumentImpl.java,v 1.1 2002/07/17 20:07:36 sandygao Exp $
   */
  public class PSVIDocumentImpl extends DocumentImpl {
  
      /**
       * Create a document.
       */
      public PSVIDocumentImpl() {
          super();
      }
  
      /**
       * For DOM2 support.
       * The createDocument factory method is in DOMImplementation.
       */
      public PSVIDocumentImpl(DocumentType doctype) {
          super(doctype);
      }
  
      /**
       * Create an element with PSVI information
       */
      public Element createElementNS(String namespaceURI, String qualifiedName)
          throws DOMException {
          return new PSVIElementNSImpl(this, namespaceURI, qualifiedName);
      }
  
      /**
       * Create an element with PSVI information
       */
      public Element createElementNS(String namespaceURI, String qualifiedName,
                                     String localpart) throws DOMException {
          return new PSVIElementNSImpl(this, namespaceURI, qualifiedName, localpart);
      }
  
      /**
       * Create an attribute with PSVI information
       */
      public Attr createAttributeNS(String namespaceURI, String qualifiedName)
          throws DOMException {
          return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName);
      } 
      
      /**
       * Create an attribute with PSVI information
       */
      public Attr createAttributeNS(String namespaceURI, String qualifiedName,
                                    String localName) throws DOMException {
          return new PSVIAttrNSImpl(this, namespaceURI, qualifiedName, localName);
      } 
      
  } // class PSVIDocumentImpl
  
  
  
  1.1                  xml-xerces/java/src/org/apache/xerces/dom/PSVIElementNSImpl.java
  
  Index: PSVIElementNSImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Xerces" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 1999, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.xerces.dom;
  
  import org.apache.xerces.xni.psvi.ElementPSVI;
  import org.apache.xerces.impl.xs.psvi.*;
  
  /**
   * Element namespace implementation; stores PSVI element items.
   * 
   * @author Sandy Gao, IBM
   * 
   * @version $Id: PSVIElementNSImpl.java,v 1.1 2002/07/17 20:07:36 sandygao Exp $
   */
  public class PSVIElementNSImpl extends ElementNSImpl implements ElementPSVI {
  
      /**
       * Construct an element node.
       */
      public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 
                               String qualifiedName, String localName) {
          super(ownerDocument, namespaceURI, qualifiedName, localName);
      }
      
      /**
       * Construct an element node.
       */
      public PSVIElementNSImpl(CoreDocumentImpl ownerDocument, String namespaceURI, 
                               String qualifiedName) {
          super(ownerDocument, namespaceURI, qualifiedName);
      }
      
      /** element declaration */
      protected XSElementDeclaration fDeclaration = null;
  
      /** type of element, could be xsi:type */
      protected XSTypeDefinition fTypeDecl = null;
  
      /** true if clause 3.2 of Element Locally Valid (Element) (3.3.4) 
        * is satisfied, otherwise false 
        */
      protected boolean fNil = false;
  
      /** false if the element value was provided by the schema; true otherwise. 
       */
      protected boolean fSpecified = true;
  
      /** schema normalized value property */
      protected String fNormalizedValue = null;
  
      /** http://www.w3.org/TR/xmlschema-1/#e-notation*/
      protected XSNotationDeclaration fNotation = null;
  
      /** member type definition against which element was validated */
      protected XSSimpleTypeDefinition fMemberType = null;
  
      /** validation attempted: none, partial, full */
      protected short fValidationAttempted = ElementPSVI.VALIDATION_NONE;
  
      /** validity: valid, invalid, unknown */
      protected short fValidity = ElementPSVI.VALIDITY_UNKNOWN;
  
      /** error codes */
      protected StringList fErrorCodes = null;
  
      /** validation context: could be QName or XPath expression*/
      protected String fValidationContext = null;
  
      /** the schema information property */
      protected XSModel fSchemaInformation = null;
      
      //
      // ElementPSVI methods
      //
  
      /**
       * [schema default]
       *
       * @return The canonical lexical representation of the declaration's {value constraint} value.
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_default>XML Schema Part 1: Structures [schema default]</a>
       */
      public String getSchemaDefault() {
          return fDeclaration == null ? null : fDeclaration.getConstraintValue();
      }
  
      /**
       * [schema normalized value]
       *
       *
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_normalized_value>XML Schema Part 1: Structures [schema normalized value]</a>
       * @return the normalized value of this item after validation
       */
      public String getSchemaNormalizedValue() {
          return fNormalizedValue;
      }
  
      /**
       * [schema specified] 
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_specified">XML Schema Part 1: Structures [schema specified]</a>
       * @return false value was specified in schema, true value comes from the infoset
       */
      public boolean getIsSchemaSpecified() {
          return fSpecified;
      }
  
      /**
       * Determines the extent to which the document has been validated
       *
       * @return return the [validation attempted] property. The possible values are
       *         NO_VALIDATION, PARTIAL_VALIDATION and FULL_VALIDATION
       */
      public short getValidationAttempted() {
          return fValidationAttempted;
      }
  
      /**
       * Determine the validity of the node with respect
       * to the validation being attempted
       *
       * @return return the [validity] property. Possible values are:
       *         UNKNOWN_VALIDITY, INVALID_VALIDITY, VALID_VALIDITY
       */
      public short getValidity() {
          return fValidity;
      }
  
      /**
       * A list of error codes generated from validation attempts.
       * Need to find all the possible subclause reports that need reporting
       *
       * @return Array of error codes
       */
      public StringList getErrorCodes() {
          return fErrorCodes;
      }
  
  
      // This is the only information we can provide in a pipeline.
      public String getValidationContext() {
          return fValidationContext;
      }
  
      /**
       * [nil]
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-nil>XML Schema Part 1: Structures [nil]</a>
       * @return true if clause 3.2 of Element Locally Valid (Element) (3.3.4) above is satisfied, otherwise false
       */
      public boolean getIsNil() {
          return fNil;
      }
  
      /**
       * [notation] 
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-notation>XML Schema Part 1: Structures [notation]</a>
       * @return The notation declaration. 
       */
      public XSNotationDeclaration getNotation() {
          return fNotation;
      }
  
      /**
       * An item isomorphic to the type definition used to validate this element.
       * 
       * @return  a type declaration
       */
      public XSTypeDefinition getTypeDefinition() {
          return fTypeDecl;
      }
      
      /**
       * If and only if that type definition is a simple type definition
       * with {variety} union, or a complex type definition whose {content type}
       * is a simple thype definition with {variety} union, then an item isomorphic
       * to that member of the union's {member type definitions} which actually
       * validated the element item's normalized value.
       * 
       * @return  a simple type declaration
       */
      public XSSimpleTypeDefinition getMemberTypeDefinition() {
          return fMemberType;
      }
  
      /**
       * An item isomorphic to the element declaration used to validate
       * this element.
       * 
       * @return  an element declaration
       */
      public XSElementDeclaration getElementDeclaration() {
          return fDeclaration;
      }
  
      /**
       * [schema information]
       * @see <a href="http://www.w3.org/TR/xmlschema-1/#e-schema_information">XML Schema Part 1: Structures [schema information]</a>
       * @return The schema information property if it's the validation root,
       *         null otherwise.
       */
      public XSModel getSchemaInformation() {
          return fSchemaInformation;
      }
      
      /**
       * Copy PSVI properties from another psvi item.
       * 
       * @param attr  the source of attribute PSVI items
       */
      public void setPSVI(ElementPSVI elem) {
          this.fDeclaration = elem.getElementDeclaration();
          this.fNotation = elem.getNotation();
          this.fValidationContext = elem.getValidationContext();
          this.fTypeDecl = elem.getTypeDefinition();
          this.fSchemaInformation = elem.getSchemaInformation();
          this.fValidity = elem.getValidity();
          this.fValidationAttempted = elem.getValidationAttempted();
          this.fErrorCodes = elem.getErrorCodes();
          this.fNormalizedValue = elem.getSchemaNormalizedValue();
          this.fMemberType = elem.getMemberTypeDefinition();
          this.fSpecified = elem.getIsSchemaSpecified();
      }
  
  }
  
  
  

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