ws-jaxme-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joc...@apache.org
Subject cvs commit: ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit MarshallerTest.java
Date Fri, 23 Jul 2004 06:50:17 GMT
jochen      2004/07/22 23:50:17

  Modified:    src/test/jaxb types.xsd
               src/jaxme/org/apache/ws/jaxme/impl JMHandlerImpl.java
               .        status.xml
               src/jaxme/org/apache/ws/jaxme/junit MarshallerTest.java
  Added:       src/jaxme/org/apache/ws/jaxme XMLConstants.java
  Log:
  Attributes in the xml namespace, the xmlns namespace, and the xsi namespace are now by default
ignored.
  PR: JAXME-17
  
  Revision  Changes    Path
  1.1                  ws-jaxme/src/jaxme/org/apache/ws/jaxme/XMLConstants.java
  
  Index: XMLConstants.java
  ===================================================================
  package org.apache.ws.jaxme;
  
  
  public class XMLConstants {
  	/** <p>The XML Schema namespace:
       * <code>http://www.w3.org/2001/XMLSchema-instance</code>
       */
      public static final String XML_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema-instance";
  
      /** <p>The attribute specifying a schema, which may
       * be used to validate the instance, if the schema
       * has a target namespace: <code>schemaLocation</code>.</p>
       * @see #XML_SCHEMA_URI
       * @see #XML_SCHEMA_NO_NS_ATTR
       */
      public static final String XML_SCHEMA_NS_ATTR = "schemaLocation";
  
      /** <p>The attribute specifying a schema, which may
       * be used to validate the instance, if the schema
       * doesn't have a namespace: <code>noNamespaceSchemaLocation</code>.</p>
       * @see #XML_SCHEMA_URI
       */
      public static final String XML_SCHEMA_NO_NS_ATTR = "noNamespaceSchemaLocation";
  }
  
  
  
  1.5       +2 -0      ws-jaxme/src/test/jaxb/types.xsd
  
  Index: types.xsd
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/test/jaxb/types.xsd,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- types.xsd	2 Jun 2004 09:09:44 -0000	1.4
  +++ types.xsd	23 Jul 2004 06:50:17 -0000	1.5
  @@ -35,6 +35,7 @@
         <xs:element name="NonPositiveIntegerElem" type="xs:nonPositiveInteger"/>
         <xs:element name="NegativeIntegerElem" type="xs:negativeInteger"/>
         <xs:element name="QNameElem" type="xs:QName"/>
  +      <xs:element name="BooleanElem" type="xs:boolean"/>
       </xs:sequence>
     </xs:complexType>
   
  @@ -63,6 +64,7 @@
       <xs:attribute name="NonPositiveIntegerAttr" type="xs:nonPositiveInteger"/>
       <xs:attribute name="NegativeIntegerAttr" type="xs:negativeInteger"/>
       <xs:attribute name="QNameAttr" type="xs:QName"/>
  +    <xs:attribute name="BooleanAttr" type="xs:boolean"/>
     </xs:complexType>
   
     <xs:simpleType name="ListType">
  
  
  
  1.6       +12 -5     ws-jaxme/src/jaxme/org/apache/ws/jaxme/impl/JMHandlerImpl.java
  
  Index: JMHandlerImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/impl/JMHandlerImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JMHandlerImpl.java	12 Apr 2004 15:09:18 -0000	1.5
  +++ JMHandlerImpl.java	23 Jul 2004 06:50:17 -0000	1.6
  @@ -19,6 +19,7 @@
   import javax.xml.bind.ValidationEvent;
   
   import org.apache.ws.jaxme.ValidationEvents;
  +import org.apache.ws.jaxme.XMLConstants;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  @@ -46,10 +47,16 @@
   
     public void addAttribute(String pNamespaceURI, String pLocalName,
                              String pValue) throws SAXException {
  -      validationEvent(ValidationEvent.ERROR,
  -                      "Unknown attribute: '" + pLocalName + "' in namespace '" +
  -                      pNamespaceURI + "'",
  -                      ValidationEvents.EVENT_UNKNOWN_ATTRIBUTE);
  +  	if (javax.xml.XMLConstants.XML_NS_URI.equals(pNamespaceURI)
  +        ||  javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(pNamespaceURI)
  +        ||  XMLConstants.XML_SCHEMA_URI.equals(pNamespaceURI)) {
  +  		// Ignore attributes in the xsi namespace
  +    } else {
  +    	validationEvent(ValidationEvent.ERROR,
  +    			        "Unknown attribute: '" + pLocalName
  +                        + "' in namespace '" + pNamespaceURI + "'",
  +						ValidationEvents.EVENT_UNKNOWN_ATTRIBUTE);
  +    }
     }
   
     public void startElement(String pNamespaceURI, String pLocalName,
  
  
  
  1.16      +15 -1     ws-jaxme/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/status.xml,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- status.xml	12 Apr 2004 15:09:18 -0000	1.15
  +++ status.xml	23 Jul 2004 06:50:17 -0000	1.16
  @@ -13,7 +13,21 @@
     </todo>
   
     <changes>
  -    <release version="0.3-dev" date="unreleased">
  +    <release version="0.3.1-dev" date="unreleased">
  +      <action dev="JW" type="fix" context="generator">
  +        If an attribute or element is mapped to the Java type "boolean",
  +        then the getter is now called "isFoo", rather than "getFoo".
  +        See JAXB SPEC, 4.5.1, and JAXME-19 in Jira.
  +      </action>
  +      <action dev="JW" type="fix" context="runtime">
  +        Attributes in the following namespaces are now by default
  +        ignored: The XML namespace (http://www.w3.org/XML/1998/namespace),
  +        the XMLNS namespace (http://www.w3.org/2000/xmlns/), and the
  +        XML Schema namespace (http://www.w3.org/2001/XMLSchema-instance).
  +        See JAXME-17 in Jira.
  +      </action>
  +    </release>
  +    <release version="0.3" date="2004-Jul-19">
         <action dev="CL" type="enhancement" context="generator">
         	Initial work on nested groups.
         </action>
  
  
  
  1.11      +19 -5     ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/MarshallerTest.java
  
  Index: MarshallerTest.java
  ===================================================================
  RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/MarshallerTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- MarshallerTest.java	8 Jul 2004 07:04:12 -0000	1.10
  +++ MarshallerTest.java	23 Jul 2004 06:50:17 -0000	1.11
  @@ -38,6 +38,7 @@
   import org.apache.ws.jaxme.JMMarshaller;
   import org.apache.ws.jaxme.JMUnmarshaller;
   import org.apache.ws.jaxme.JMXmlSerializer;
  +import org.apache.ws.jaxme.XMLConstants;
   import org.apache.ws.jaxme.XMLWriter;
   import org.apache.ws.jaxme.impl.JAXBContextImpl;
   import org.apache.ws.jaxme.impl.JMMarshallerImpl;
  @@ -139,6 +140,7 @@
       element.setNonPositiveIntegerElem(new BigInteger("-21714"));
       element.setNegativeIntegerElem(new BigInteger("-21714"));
       element.setQNameElem(new QName("http://ws.apache.org/jaxme/test/misc/types", "ias"));
  +    element.setBooleanElem(true);
       return element;
     }
   
  @@ -179,14 +181,18 @@
         "<ex:NonPositiveIntegerElem>-21714</ex:NonPositiveIntegerElem>" +
         "<ex:NegativeIntegerElem>-21714</ex:NegativeIntegerElem>" +
         "<ex:QNameElem>ex:ias</ex:QNameElem>" +
  +      "<ex:BooleanElem>true</ex:BooleanElem>" +
         "</ex:AllSimpleTypesElement>";
     }
   
  -  public String getAllTypesElementString() {
  +  private String getAllTypesElementString(boolean pSchemaDeclaration) {
       AllTypesElementImpl elem = new AllTypesElementImpl();
       String uri = elem.getQName().getNamespaceURI();
  +    String xsi = pSchemaDeclaration ? " xmlns:xsi=\""
  +    	+ XMLConstants.XML_SCHEMA_URI + "\" xsi:"
  +        + XMLConstants.XML_SCHEMA_NS_ATTR + "=\"foo.xsd\"" : "";
       return
  -      "<ex:AllTypesElement xmlns:ex=\"" + uri + "\">\n" +
  +      "<ex:AllTypesElement xmlns:ex=\"" + uri + "\"" + xsi + ">\n" +
         "  <ex:AllSimpleTypesElement>\n" +
         "    <ex:StringElem>This is a string with german Umlauts: &#228;&#246;&#252;&#223;&#196;&#214;&#220;</ex:StringElem>\n"
+
         "    <ex:IntElem>-2139879</ex:IntElem>\n" +
  @@ -209,6 +215,7 @@
         "    <ex:NonPositiveIntegerElem>-21714</ex:NonPositiveIntegerElem>\n"
+
         "    <ex:NegativeIntegerElem>-21714</ex:NegativeIntegerElem>\n" +
         "    <ex:QNameElem>ex:ias</ex:QNameElem>\n" +
  +      "    <ex:BooleanElem>true</ex:BooleanElem>\n" +
         "  </ex:AllSimpleTypesElement>\n" +
         "  <ex:ListTypeElement>7 -3 0</ex:ListTypeElement>\n" +
         "  <ex:UnionTypeElement>2002-11-22T16:43:37Z</ex:UnionTypeElement>\n"
+
  @@ -241,6 +248,7 @@
       assertEquals(getHexBytes(), pElement.getHexBinaryElem());
       assertEquals(getHexBytes(), pElement.getBase64BinaryElem());
       assertEquals(new BigInteger("101"), pElement.getNonNegativeIntegerElem());
  +    assertTrue(pElement.isBooleanElem());
     }
   
     public void verifyAllTypesElement(AllTypesElement pElement) {
  @@ -273,9 +281,15 @@
     /** <p>Tests, whether complex elements can be marshalled.</p>
      */
     public void testUnmarshalComplexElements() throws Exception {
  +    testUnmarshalComplexElements(false);
  +    testUnmarshalComplexElements(true);
  +  }
  +
  +  private void testUnmarshalComplexElements(boolean pSchemaLocation)
  +      throws Exception {
       JAXBContext myFactory = getFactory();
       Unmarshaller unmarshaller = myFactory.createUnmarshaller();
  -    String s = getAllTypesElementString();
  +    String s = getAllTypesElementString(pSchemaLocation);
       StringReader sr = new StringReader(s);
       AllTypesElement result = (AllTypesElement) unmarshaller.unmarshal(new InputSource(sr));
       verifyAllTypesElement(result);
  @@ -302,7 +316,7 @@
       Class c = marshaller.getXMLWriterClass();
       XMLWriter w = (XMLWriter) c.newInstance();
       w.init(marshaller);
  -    String rawInput = getAllTypesElementString();
  +    String rawInput = getAllTypesElementString(false);
       StringBuffer input = new StringBuffer();
       for (int i = 0;  i < rawInput.length();  i++) {
         char ch = rawInput.charAt(i);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Mime
View raw message