xml-xmlbeans-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ce...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/validator ValidatingInfoXMLStreamReader.java Validator.java
Date Tue, 17 Aug 2004 21:38:49 GMT
cezar       2004/08/17 14:38:49

  Modified:    v2/src/typeimpl/org/apache/xmlbeans/impl/validator
                        Validator.java
  Added:       v2/src/typeimpl/org/apache/xmlbeans/impl/validator
                        ValidatingInfoXMLStreamReader.java
  Log:
  - adding getCurrentElementSchemaType in Validator for finding schema types of elements with
xsi:type attribute.
  - fixed getList value when list type contains an union.
  - adding ValidatingInfoXMLStreamReader for PSVI access on XMLStreamReaders.
  
  checkintests pass
  
  Revision  Changes    Path
  1.15      +34 -1     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/validator/Validator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Validator.java	9 Aug 2004 23:45:47 -0000	1.14
  +++ Validator.java	17 Aug 2004 21:38:48 -0000	1.15
  @@ -1516,7 +1516,8 @@
   
       private void addToList(SchemaType type)
       {
  -        if (type.getSimpleVariety() != SchemaType.ATOMIC)
  +        if (type.getSimpleVariety() != SchemaType.ATOMIC &&
  +            type.getSimpleVariety() != SchemaType.UNION)
               return;
   
           if (type.getUnionMemberTypes().length>0 && getUnionType()!=null)
  @@ -1672,6 +1673,27 @@
           _localAttribute = null;
       }
   
  +    /**
  +     * @return Returns the SchemaType of the current element.
  +     * This can be different than getCurrentElement().getType() if xsi:type attribute is
used.
  +     * Null is returned if no schema type is available.
  +     * For attribute types use {@link #getCurrentAttribute()}.getType().
  +     * Warning: the returned SchemaType can be an {@link org.apache.xmlbeans.XmlBeans#NO_TYPE},
  +     * see {@link SchemaType#isNoType}. Or can be the parent type, for unrecognized elements
  +     * that are part of wildcards.
  +     */
  +    public SchemaType getCurrentElementSchemaType ( )
  +    {
  +        State state = topState();
  +        if (state!=null)
  +            return state._type;
  +
  +        return null;
  +    }
  +
  +    /**
  +     * @return Returns the curent local element, null if one is not available, see {@link
#getCurrentWildcardElement()}.
  +     */
       public SchemaLocalElement getCurrentElement ( )
       {
           if (_localElement != null)
  @@ -1690,16 +1712,27 @@
           return null;
       }
   
  +    /**
  +     * @return Returns the current particle, if this is a wildcard particle {@link SchemaParticle#WILDCARD}
  +     * method {@link #getCurrentElement()} might return null if wildcard's processContents
is skip or lax.
  +     */
       public SchemaParticle getCurrentWildcardElement()
       {
           return _wildcardElement;
       }
   
  +    /**
  +     * @return Returns the curent local attribute, global attribute if the current attribute
is part of an
  +     * attribute wildcard, or null if none is available.
  +     */
       public SchemaLocalAttribute getCurrentAttribute()
       {
           return _localAttribute;
       }
   
  +    /**
  +     * @return Returns the attribute model for attributes if available, else null is returned.
  +     */
       public SchemaAttributeModel getCurrentWildcardAttribute()
       {
           return _wildcardAttribute;
  
  
  
  1.1                  xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/validator/ValidatingInfoXMLStreamReader.java
  
  Index: ValidatingInfoXMLStreamReader.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed 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.xmlbeans.impl.validator;
  
  import org.apache.xmlbeans.SchemaType;
  import org.apache.xmlbeans.SchemaLocalElement;
  import org.apache.xmlbeans.SchemaParticle;
  import org.apache.xmlbeans.SchemaLocalAttribute;
  import org.apache.xmlbeans.SchemaAttributeModel;
  import org.apache.xmlbeans.GDate;
  import org.apache.xmlbeans.GDuration;
  
  import javax.xml.stream.XMLStreamReader;
  import javax.xml.namespace.QName;
  import java.math.BigDecimal;
  import java.util.List;
  
  /**
   * Extension of {@link ValidatingXMLInputStream} to provide Post Schema Validation Info
   * over an XMLSchemaReader.
   *
   * @author Cezar Andrei (cezar.andrei at bea.com)
   *         Date: Aug 17, 2004
   */
  public class ValidatingInfoXMLStreamReader
      extends ValidatingXMLStreamReader
      implements XMLStreamReader
  {
      public ValidatingInfoXMLStreamReader()
      {
          super();
      }
  
      /**
       * @return Returns the SchemaType of the current element.
       * This can be different than getCurrentElement().getType() if xsi:type attribute is
used.
       * Null is returned if no schema type is available.
       * For attribute types use {@link #getCurrentAttribute()}.getType().
       * Warning: the returned SchemaType can be an {@link org.apache.xmlbeans.XmlBeans#NO_TYPE},
       * see {@link org.apache.xmlbeans.SchemaType#isNoType}. Or can be the parent type, for
unrecognized elements
       * that are part of wildcards.
       */
      public SchemaType getCurrentElementSchemaType()
      {
          return _validator.getCurrentElementSchemaType();
      }
  
      /**
       * @return Returns the curent local element, null if one is not available, see {@link
#getCurrentWildcardElement()}.
       */
      public SchemaLocalElement getCurrentElement ( )
      {
          return _validator.getCurrentElement();
      }
  
      /**
       * @return Returns the current particle, if this is a wildcard particle
       * {@link org.apache.xmlbeans.SchemaParticle#WILDCARD} method {@link #getCurrentElement()}
       * might return null if wildcard's processContents is skip or lax.
       */
      public SchemaParticle getCurrentWildcardElement()
      {
          return _validator.getCurrentWildcardElement();
      }
  
      /**
       * @return Returns the curent local attribute, global attribute if the current attribute
is part of an
       * attribute wildcard, or null if none is available.
       */
      public SchemaLocalAttribute getCurrentAttribute()
      {
          return _validator.getCurrentAttribute();
      }
  
      /**
       * @return Returns the attribute model for attributes if available, else null is returned.
       */
      public SchemaAttributeModel getCurrentWildcardAttribute()
      {
          return _validator.getCurrentWildcardAttribute();
      }
  
      public String getStringValue()
      {
          return _validator.getStringValue();
      }
  
      public BigDecimal getDecimalValue()
      {
          return _validator.getDecimalValue();
      }
  
      public boolean getBooleanValue()
      {
          return _validator.getBooleanValue();
      }
  
      public float getFloatValue()
      {
          return _validator.getFloatValue();
      }
  
      public double getDoubleValue()
      {
          return _validator.getDoubleValue();
      }
  
      public QName getQNameValue()
      {
          return _validator.getQNameValue();
      }
  
      public GDate getGDateValue()
      {
          return _validator.getGDateValue();
      }
  
      public GDuration getGDurationValue()
      {
          return _validator.getGDurationValue();
      }
  
      public byte[] getByteArrayValue()
      {
          return _validator.getByteArrayValue();
      }
  
      public List getListValue()
      {
          return _validator.getListValue();
      }
  
      public List getListTypes()
      {
          return _validator.getListTypes();
      }
  
      public SchemaType getUnionType()
      {
          return _validator.getUnionType();
      }
  }
  
  
  

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


Mime
View raw message