commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject cvs commit: jakarta-commons/betwixt/src/resources dotbetwixt.dtd
Date Wed, 01 Dec 2004 21:07:14 GMT
rdonkin     2004/12/01 13:07:14

  Modified:    betwixt/src/java/org/apache/commons/betwixt/digester
                        ElementRule.java
               betwixt/src/resources dotbetwixt.dtd
  Log:
  Allowed anonymous mixed collections to be specified in a dot betwixt file.
  
  Revision  Changes    Path
  1.19      +16 -17    jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java
  
  Index: ElementRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/digester/ElementRule.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ElementRule.java	8 Nov 2004 22:29:11 -0000	1.18
  +++ ElementRule.java	1 Dec 2004 21:07:13 -0000	1.19
  @@ -70,21 +70,11 @@
       public void begin(String name, String namespace, Attributes attributes) throws SAXException
{
           String nameAttributeValue = attributes.getValue( "name" );
           
  -        // check that the name attribute is present 
  -        if ( nameAttributeValue == null || nameAttributeValue.trim().equals( "" ) ) {
  -            throw new SAXException("Name attribute is required.");
  -        }
  -        
  -        // check that name is well formed 
  -        if ( !XMLUtils.isWellFormedXMLName( nameAttributeValue ) ) {
  -            throw new SAXException("'" + nameAttributeValue + "' would not be a well formed
xml element name.");
  -        }
  -        
           ElementDescriptor descriptor = new ElementDescriptor();
           descriptor.setLocalName( nameAttributeValue );
           String uri = attributes.getValue( "uri" );
           String qName = nameAttributeValue;
  -        if ( uri != null ) {
  +        if ( uri != null && nameAttributeValue != null) {
               descriptor.setURI( uri );  
               String prefix = getXMLIntrospector().getConfiguration().getPrefixMapper().getPrefix(uri);
               qName = prefix + ":" + nameAttributeValue;
  @@ -115,8 +105,21 @@
               getPropertyType( propertyType, beanClass, propertyName ) 
           );
           
  -        descriptor.setCollective(getXMLIntrospector().getConfiguration()
  -                .isLoopType(descriptor.getPropertyType()));
  +        boolean isCollective = getXMLIntrospector().getConfiguration()
  +        .isLoopType(descriptor.getPropertyType());
  +        
  +        descriptor.setCollective(isCollective);
  +        
  +        // check that the name attribute is present 
  +        if ( !isCollective && (nameAttributeValue == null || nameAttributeValue.trim().equals(
"" ) )) {
  +            throw new SAXException("Name attribute is required.");
  +        }
  +        
  +        // check that name is well formed 
  +        if ( nameAttributeValue != null && !XMLUtils.isWellFormedXMLName( nameAttributeValue
) ) {
  +            throw new SAXException("'" + nameAttributeValue + "' would not be a well formed
xml element name.");
  +        }
  +        
           
           String implementationClass = attributes.getValue( "class" );
           if ( log.isTraceEnabled() ) {
  @@ -239,10 +242,6 @@
           Method readMethod = propertyDescriptor.getReadMethod();
           Method writeMethod = propertyDescriptor.getWriteMethod();
           
  -        String existingLocalName = elementDescriptor.getLocalName();
  -        if (existingLocalName == null || "".equals(existingLocalName)) {
  -            elementDescriptor.setLocalName( propertyDescriptor.getName() );
  -        }
           elementDescriptor.setPropertyType( type );        
           
           // TODO: associate more bean information with the descriptor?
  
  
  
  1.11      +4 -2      jakarta-commons/betwixt/src/resources/dotbetwixt.dtd
  
  Index: dotbetwixt.dtd
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/betwixt/src/resources/dotbetwixt.dtd,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- dotbetwixt.dtd	23 Sep 2004 21:46:00 -0000	1.10
  +++ dotbetwixt.dtd	1 Dec 2004 21:07:13 -0000	1.11
  @@ -45,10 +45,12 @@
       
       the (optional) class attribute specifies an implementation class that should
       be used for instantiation (as opposed to the type of the property)
  +    
  +    Note that name is required except when the property is a collective
   -->
   <!ELEMENT element (attribute|addDefaults|element|text)*>
   <!ATTLIST element
  -    name CDATA #REQUIRED
  +    name CDATA #IMPLIED 
       type CDATA #IMPLIED
       uri CDATA #IMPLIED
       value CDATA #IMPLIED
  
  
  

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


Mime
View raw message