You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by zi...@apache.org on 2004/01/12 08:26:02 UTC

cvs commit: xml-xmlbeans/v2/test/cases/marshal doc.xml example_config.xml

zieg        2004/01/11 23:26:02

  Modified:    v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        QNameProperty.java SimpleBindingType.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        BindingContextFactoryImpl.java
                        ByNameRuntimeBindingType.java
                        StringTypeConverter.java UnmarshallerImpl.java
               v2/src/marshal/org/apache/xmlbeans/impl/richParser
                        XMLStreamReaderExtImpl.java
               v2/test/cases/marshal doc.xml example_config.xml
  Added:       v2/src/marshal/org/apache/xmlbeans/impl/marshal
                        CollapseStringTypeConverter.java
                        PreserveStringTypeConverter.java
                        ReplaceStringTypeConverter.java
  Log:
  added support for whitespace facets and defaults to binding-config
  schema and corresponding bts classes
  
  added support for whitespace facet processing to marshal runtime
  (defaults coming soon)
  
  DRT: passed
  
  Revision  Changes    Path
  1.3       +13 -1     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/QNameProperty.java
  
  Index: QNameProperty.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/QNameProperty.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QNameProperty.java	7 Nov 2003 22:28:29 -0000	1.2
  +++ QNameProperty.java	12 Jan 2004 07:26:01 -0000	1.3
  @@ -70,7 +70,8 @@
       private boolean isMultiple;
       private boolean isOptional;
       private boolean isNillable;
  -    
  +    private String defaultValue;
  +
       public QNameProperty()
       {
           super();
  @@ -86,6 +87,7 @@
           isMultiple = qpNode.getMultiple();
           isNillable = qpNode.getNillable();
           isOptional = qpNode.getOptional();
  +        defaultValue = qpNode.getDefault();
       }
       
       /**
  @@ -160,5 +162,15 @@
       public void setNillable(boolean nillable)
       {
           isNillable = nillable;
  +    }
  +
  +    public String getDefault()
  +    {
  +        return defaultValue;
  +    }
  +
  +    public void setDefault(String default_value)
  +    {
  +        defaultValue = default_value;
       }
   }
  
  
  
  1.5       +76 -3     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleBindingType.java
  
  Index: SimpleBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleBindingType.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleBindingType.java	4 Dec 2003 21:14:55 -0000	1.4
  +++ SimpleBindingType.java	12 Jan 2004 07:26:01 -0000	1.5
  @@ -56,6 +56,7 @@
   package org.apache.xmlbeans.impl.binding.bts;
   
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  +import org.apache.xmlbeans.impl.common.XmlWhitespace;
   
   /**
    * A binding of a simple user-defined type that operates by
  @@ -63,6 +64,10 @@
    */ 
   public class SimpleBindingType extends BindingType
   {
  +    private XmlTypeName asIfXmlType;
  +    private int whitespace = XmlWhitespace.WS_UNSPECIFIED;
  +
  +
       public SimpleBindingType(BindingTypeName btName)
       {
           super(btName);
  @@ -72,17 +77,53 @@
       {
           super(node);
           org.apache.xml.xmlbeans.bindingConfig.SimpleType stNode = (org.apache.xml.xmlbeans.bindingConfig.SimpleType)node;
  -        asIfXmlType = XmlTypeName.forString(stNode.getAsXml());
  +        org.apache.xml.xmlbeans.bindingConfig.AsXmlType as_xml = stNode.getAsXml();
  +        asIfXmlType = XmlTypeName.forString(as_xml.getStringValue());
  +
  +        if (as_xml.isSetWhitespace()) {
  +            org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.Enum ws =
  +                as_xml.getWhitespace();
  +            if (ws.equals(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.PRESERVE)) {
  +                whitespace = XmlWhitespace.WS_PRESERVE;
  +            } else if (ws.equals(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.REPLACE)) {
  +                whitespace = XmlWhitespace.WS_REPLACE;
  +            } else if (ws.equals(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.COLLAPSE)) {
  +                whitespace = XmlWhitespace.WS_COLLAPSE;
  +            } else {
  +                throw new AssertionError("invalid whitespace: " + ws);
  +            }
  +
  +        }
       }
   
       protected org.apache.xml.xmlbeans.bindingConfig.BindingType write(org.apache.xml.xmlbeans.bindingConfig.BindingType node)
       {
           org.apache.xml.xmlbeans.bindingConfig.SimpleType stNode = (org.apache.xml.xmlbeans.bindingConfig.SimpleType)super.write(node);
  -        stNode.setAsXml(asIfXmlType.toString());
  +
  +        org.apache.xml.xmlbeans.bindingConfig.AsXmlType as_if = stNode.addNewAsXml();
  +        as_if.setStringValue(asIfXmlType.toString());
  +
  +        switch (whitespace) {
  +            case XmlWhitespace.WS_UNSPECIFIED:
  +                break;
  +            case XmlWhitespace.WS_PRESERVE:
  +                as_if.setWhitespace(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.PRESERVE);
  +                break;
  +            case XmlWhitespace.WS_REPLACE:
  +                as_if.setWhitespace(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.REPLACE);
  +                break;
  +            case XmlWhitespace.WS_COLLAPSE:
  +                as_if.setWhitespace(org.apache.xml.xmlbeans.bindingConfig.AsXmlType.Whitespace.COLLAPSE);
  +                break;
  +            default:
  +                throw new AssertionError("invalid whitespace: " + whitespace);
  +        }
  +
  +
  +        stNode.setAsXml(as_if);
           return stNode;
       }
   
  -    private XmlTypeName asIfXmlType;
   
       // typically the "as if" type is the closest base builtin type.
       public XmlTypeName getAsIfXmlType()
  @@ -100,5 +141,37 @@
       public BindingTypeName getAsIfBindingTypeName()
       {
           return BindingTypeName.forPair(getName().getJavaName(), asIfXmlType);
  +    }
  +
  +
  +    /**
  +     * Gets whitespace facet -- use the constants from
  +     * org.apache.xmlbeans.impl.common.XmlWhitespace
  +     *
  +     * @return whitespace constant from XmlWhitespace
  +     */
  +    public int getWhitespace()
  +    {
  +        return whitespace;
  +    }
  +
  +    /**
  +     * Sets whitespace facet -- use the constants from
  +     * org.apache.xmlbeans.impl.common.XmlWhitespace
  +     *
  +     * @param ws  whitespace constant from XmlWhitespace
  +     */
  +    public void setWhitespace(int ws)
  +    {
  +        switch (ws) {
  +            case XmlWhitespace.WS_UNSPECIFIED:
  +            case XmlWhitespace.WS_PRESERVE:
  +            case XmlWhitespace.WS_REPLACE:
  +            case XmlWhitespace.WS_COLLAPSE:
  +                whitespace = ws;
  +                break;
  +            default:
  +                throw new IllegalArgumentException("invalid whitespace: " + ws);
  +        }
       }
   }
  
  
  
  1.12      +18 -1     xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd
  
  Index: binding-config.xsd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- binding-config.xsd	16 Dec 2003 09:55:05 -0000	1.11
  +++ binding-config.xsd	12 Jan 2004 07:26:01 -0000	1.12
  @@ -48,7 +48,7 @@
       <xs:complexContent>
         <xs:extension base="tns:binding-type">
           <xs:sequence>
  -          <xs:element name="as-xml" type="tns:xml-signature"/>
  +          <xs:element name="as-xml" type="tns:as-xml-type"/>
           </xs:sequence>
         </xs:extension>
       </xs:complexContent>
  @@ -122,6 +122,7 @@
             <xs:element name="multiple" type="xs:boolean" default="false" minOccurs="0"/>
             <xs:element name="nillable" type="xs:boolean" default="false" minOccurs="0"/>
             <xs:element name="optional" type="xs:boolean" default="false" minOccurs="0"/>
  +          <xs:element name="default" type="xs:string" minOccurs="0"/>
           </xs:sequence>
         </xs:extension>
       </xs:complexContent>
  @@ -152,6 +153,22 @@
       <xs:restriction base="xs:token">
       </xs:restriction>
     </xs:simpleType>
  +
  +  <xs:complexType name="as-xml-type">
  +    <xs:simpleContent>
  +      <xs:extension base="tns:xml-signature">
  +        <xs:attribute name="whitespace">
  +          <xs:simpleType>     <!--type defn copied from schema for schemas-->
  +            <xs:restriction base="xs:NMTOKEN">
  +              <xs:enumeration value="preserve"/>
  +              <xs:enumeration value="replace"/>
  +              <xs:enumeration value="collapse"/>
  +            </xs:restriction>
  +          </xs:simpleType>
  +        </xs:attribute>
  +      </xs:extension>
  +    </xs:simpleContent>
  +  </xs:complexType>
   
     <xs:simpleType name="java-property-name">
       <xs:restriction base="xs:token">
  
  
  
  1.8       +68 -20    xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactoryImpl.java
  
  Index: BindingContextFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/BindingContextFactoryImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BindingContextFactoryImpl.java	17 Dec 2003 02:09:19 -0000	1.7
  +++ BindingContextFactoryImpl.java	12 Jan 2004 07:26:01 -0000	1.8
  @@ -60,17 +60,21 @@
   import org.apache.xmlbeans.BindingContext;
   import org.apache.xmlbeans.BindingContextFactory;
   import org.apache.xmlbeans.XmlException;
  +import org.apache.xmlbeans.XmlRuntimeException;
   import org.apache.xmlbeans.impl.binding.bts.BindingFile;
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
  +import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
   import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingLoader;
  +import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingType;
   import org.apache.xmlbeans.impl.binding.bts.ByNameBean;
   import org.apache.xmlbeans.impl.binding.bts.PathBindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
  -import org.apache.xmlbeans.impl.binding.tylar.Tylar;
   import org.apache.xmlbeans.impl.binding.tylar.DefaultTylarLoader;
  +import org.apache.xmlbeans.impl.binding.tylar.Tylar;
   import org.apache.xmlbeans.impl.binding.tylar.TylarLoader;
  +import org.apache.xmlbeans.impl.common.XmlWhitespace;
   
   import java.io.File;
   import java.io.IOException;
  @@ -84,21 +88,21 @@
   public final class BindingContextFactoryImpl
       extends BindingContextFactory
   {
  -
  -  public BindingContext createBindingContext(URI[] tylarUris)
  -          throws IOException, XmlException {
  -    if (tylarUris == null) throw new IllegalArgumentException("null uris");
  -    //FIXME loader needs to be pluggable
  -    TylarLoader loader = DefaultTylarLoader.getInstance();
  -    if (loader == null) throw new IllegalArgumentException("null loader");
  -    Tylar[] tylars = new Tylar[tylarUris.length];
  -    for (int i = 0; i < tylars.length; i++) {
  -      tylars[i] = loader.load(tylarUris[i]);
  +    public BindingContext createBindingContext(URI[] tylarUris)
  +        throws IOException, XmlException
  +    {
  +        if (tylarUris == null) throw new IllegalArgumentException("null uris");
  +        //FIXME loader needs to be pluggable
  +        TylarLoader loader = DefaultTylarLoader.getInstance();
  +        if (loader == null) throw new IllegalArgumentException("null loader");
  +        Tylar[] tylars = new Tylar[tylarUris.length];
  +        for (int i = 0; i < tylars.length; i++) {
  +            tylars[i] = loader.load(tylarUris[i]);
  +        }
  +        return createBindingContext(tylars);
       }
  -    return createBindingContext(tylars);
  -  }
   
  -  // REVIEW It's unfortunate that we can't expose this method to the public
  +    // REVIEW It's unfortunate that we can't expose this method to the public
       // at the moment.  It's easy to imagine cases where one has already built
       // up the tylar and doesn't want to pay the cost of re-parsing it.
       // Of course, exposing it means we expose Tylar to the public as well,
  @@ -222,15 +226,59 @@
           TypeUnmarshaller um = table.getTypeUnmarshaller(stype);
           if (um != null) return um;
   
  -        //let's try using the as if type
  -        BindingType asif = loader.getBindingType(stype.getAsIfBindingTypeName());
  -        if (asif == null) {
  -            throw new AssertionError("unable to get asif type for " + stype);
  +
  +        int curr_ws = XmlWhitespace.WS_UNSPECIFIED;
  +        SimpleBindingType curr = stype;
  +        BuiltinBindingType resolved = null;
  +
  +        while (true) {
  +            //we want to keep the first whitespace setting as we walk up
  +            if (curr_ws == XmlWhitespace.WS_UNSPECIFIED) {
  +                curr_ws = curr.getWhitespace();
  +            }
  +
  +            BindingTypeName asif_name = curr.getAsIfBindingTypeName();
  +            if (asif_name != null) {
  +                BindingType asif_new = loader.getBindingType(asif_name);
  +                if (asif_new instanceof BuiltinBindingType) {
  +                    resolved = (BuiltinBindingType)asif_new;
  +                    break;
  +                } else if (asif_new instanceof SimpleBindingType) {
  +                    curr = (SimpleBindingType)asif_new;
  +                } else {
  +                    String msg = "invalid as-xml type: " + asif_name +
  +                        " on type: " + curr.getName();
  +                    throw new XmlRuntimeException(msg);
  +                }
  +            } else {
  +                throw new XmlRuntimeException("missing as-xml type on " +
  +                                              curr.getName());
  +            }
  +        }
  +        assert resolved != null;
  +
  +
  +        //special processing for whitespace facets.
  +        //TODO: assert that our type is derived from xsd:string
  +        switch (curr_ws) {
  +            case XmlWhitespace.WS_UNSPECIFIED:
  +                break;
  +            case XmlWhitespace.WS_PRESERVE:
  +                return PreserveStringTypeConverter.getInstance();
  +            case XmlWhitespace.WS_REPLACE:
  +                return ReplaceStringTypeConverter.getInstance();
  +            case XmlWhitespace.WS_COLLAPSE:
  +                return CollapseStringTypeConverter.getInstance();
  +            default:
  +                throw new AssertionError("invalid whitespace: " + curr_ws);
           }
  -        um = table.getTypeUnmarshaller(asif);
  +
  +
  +        um = table.getTypeUnmarshaller(resolved);
           if (um != null) return um;
   
  -        String msg = "unable to get simple type unmarshaller for " + stype + " using asif=" + asif;
  +        String msg = "unable to get simple type unmarshaller for " + stype +
  +            " resolved to " + resolved;
           throw new AssertionError(msg);
       }
   
  
  
  
  1.16      +1 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameRuntimeBindingType.java
  
  Index: ByNameRuntimeBindingType.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ByNameRuntimeBindingType.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ByNameRuntimeBindingType.java	19 Dec 2003 18:08:31 -0000	1.15
  +++ ByNameRuntimeBindingType.java	12 Jan 2004 07:26:01 -0000	1.16
  @@ -349,6 +349,7 @@
               TypeMarshaller m = typeTable.getTypeMarshaller(bindingType);
   
               if (m == null) {
  +                //TODO: FIXME for nested as-if types
                   if (bindingType instanceof SimpleBindingType) {
                       SimpleBindingType stype = (SimpleBindingType)bindingType;
   
  
  
  
  1.5       +2 -3      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/StringTypeConverter.java
  
  Index: StringTypeConverter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/StringTypeConverter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- StringTypeConverter.java	15 Dec 2003 05:03:30 -0000	1.4
  +++ StringTypeConverter.java	12 Jan 2004 07:26:01 -0000	1.5
  @@ -58,13 +58,12 @@
   
   import org.apache.xmlbeans.impl.util.XsTypeConverter;
   
  -final class StringTypeConverter
  +class StringTypeConverter
       extends BaseSimpleTypeConverter
   {
       protected Object getObject(UnmarshallerImpl context)
       {
  -        String val = context.getStringValue();
  -        return val;
  +        return context.getStringValue();
       }
   
       public Object unmarshalAttribute(UnmarshallerImpl context)
  
  
  
  1.13      +10 -0     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshallerImpl.java
  
  Index: UnmarshallerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/UnmarshallerImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- UnmarshallerImpl.java	7 Jan 2004 07:29:53 -0000	1.12
  +++ UnmarshallerImpl.java	12 Jan 2004 07:26:01 -0000	1.13
  @@ -315,6 +315,16 @@
           }
       }
   
  +    String getStringValue(int ws)
  +    {
  +        try {
  +            return baseReader.getStringValue(ws);
  +        }
  +        catch (XMLStreamException e) {
  +            throw new XmlRuntimeException(e);
  +        }
  +    }
  +
       boolean getBooleanValue()
       {
           try {
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/CollapseStringTypeConverter.java
  
  Index: CollapseStringTypeConverter.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.impl.common.XmlWhitespace;
  
  
  final class CollapseStringTypeConverter
      extends StringTypeConverter
  {
      private static final TypeConverter INSTANCE
          = new CollapseStringTypeConverter();
  
      static TypeConverter getInstance() {
          return INSTANCE;
      }
  
      private CollapseStringTypeConverter()
      {
      }
  
      protected Object getObject(UnmarshallerImpl context)
      {
          return context.getStringValue(XmlWhitespace.WS_COLLAPSE);
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/PreserveStringTypeConverter.java
  
  Index: PreserveStringTypeConverter.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.impl.common.XmlWhitespace;
  
  
  final class PreserveStringTypeConverter
      extends StringTypeConverter
  {
      private static final TypeConverter INSTANCE
          = new PreserveStringTypeConverter();
  
      static TypeConverter getInstance() {
          return INSTANCE;
      }
  
      private PreserveStringTypeConverter()
      {
      }
  
      protected Object getObject(UnmarshallerImpl context)
      {
          return context.getStringValue(XmlWhitespace.WS_PRESERVE);
      }
  
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/ReplaceStringTypeConverter.java
  
  Index: ReplaceStringTypeConverter.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 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 "Apache" 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
  *    XMLBeans", 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) 2000-2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.marshal;
  
  import org.apache.xmlbeans.impl.common.XmlWhitespace;
  
  
  final class ReplaceStringTypeConverter
      extends StringTypeConverter
  {
      private static final TypeConverter INSTANCE
          = new ReplaceStringTypeConverter();
  
      static TypeConverter getInstance() {
          return INSTANCE;
      }
  
      private ReplaceStringTypeConverter()
      {
      }
  
      protected Object getObject(UnmarshallerImpl context)
      {
          return context.getStringValue(XmlWhitespace.WS_REPLACE);
      }
  
  }
  
  
  
  1.4       +5 -0      xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/richParser/XMLStreamReaderExtImpl.java
  
  Index: XMLStreamReaderExtImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/richParser/XMLStreamReaderExtImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLStreamReaderExtImpl.java	13 Dec 2003 00:01:58 -0000	1.3
  +++ XMLStreamReaderExtImpl.java	12 Jan 2004 07:26:02 -0000	1.4
  @@ -109,6 +109,8 @@
           throws XMLStreamException
       {
           _charSeq.reload(CharSeqTrimWS.XMLWHITESPACE_PRESERVE);
  +        //REVIEW zieg 2004-01-11 - we should write a collapse method
  +        //that takes a CharSequence to void creating this extra String object
           return XmlWhitespace.collapse(_charSeq.toString(), wsStyle);
       }
   
  @@ -1050,6 +1052,9 @@
   
           private static Location copyLocation(Location loc)
           {
  +            //REVIEW zieg 2004-01-11 this extra object is hurting perf.  Can we
  +            //somehow defer this until we need it, or just copy the
  +            //values without creating a new object?
               return new ExtLocation(loc.getLineNumber(), loc.getColumnNumber(), loc.getCharacterOffset(),
                   loc.getPublicId(), loc.getSystemId());
           }
  
  
  
  1.10      +1 -1      xml-xmlbeans/v2/test/cases/marshal/doc.xml
  
  Index: doc.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/doc.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- doc.xml	15 Dec 2003 05:03:32 -0000	1.9
  +++ doc.xml	12 Jan 2004 07:26:02 -0000	1.10
  @@ -30,7 +30,7 @@
       </My:Myelt>
   
       <!--    test as-if for simple types-->
  -    <My:Myatt xsi:nil=" false " xsi:type="My:custom-string">some string</My:Myatt>
  +    <My:Myatt xsi:nil=" false " xsi:type="My:custom-string"> collapse   me! </My:Myatt>
   
   </My:load>
   
  
  
  
  1.16      +2 -1      xml-xmlbeans/v2/test/cases/marshal/example_config.xml
  
  Index: example_config.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/cases/marshal/example_config.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- example_config.xml	7 Jan 2004 07:29:53 -0000	1.15
  +++ example_config.xml	12 Jan 2004 07:26:02 -0000	1.16
  @@ -4,7 +4,7 @@
           <bin:binding-type xsi:type="bin:simple-type" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
               <bin:xmlcomponent>t=custom-string@java:com.mytest</bin:xmlcomponent>
               <bin:javatype>java.lang.String</bin:javatype>
  -            <bin:as-xml>t=string@http://www.w3.org/2001/XMLSchema</bin:as-xml>
  +            <bin:as-xml whitespace="collapse">t=string@http://www.w3.org/2001/XMLSchema</bin:as-xml>
           </bin:binding-type>
   
           <bin:binding-type xsi:type="bin:by-name-bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  @@ -22,6 +22,7 @@
                   </bin:setter>
                   <bin:qname>java:Attrib</bin:qname>
                   <bin:attribute>true</bin:attribute>
  +                <bin:default>9.12321</bin:default>
               </bin:qname-property>
               <bin:qname-property>
                   <bin:xmlcomponent>t=MyClass@java:com.mytest</bin:xmlcomponent>
  
  
  

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