xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z...@apache.org
Subject cvs commit: xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util AttributeHolder.java
Date Fri, 16 Apr 2004 05:36:44 GMT
zieg        2004/04/15 22:36:43

  Modified:    v2/src/marshal/org/apache/xmlbeans/impl/marshal/util
                        AttributeHolder.java
  Log:
  fix QName creation bug when attributes are not in a namespace
  
  Revision  Changes    Path
  1.2       +19 -6     xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/AttributeHolder.java
  
  Index: AttributeHolder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/marshal/org/apache/xmlbeans/impl/marshal/util/AttributeHolder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributeHolder.java	12 Apr 2004 22:39:46 -0000	1.1
  +++ AttributeHolder.java	16 Apr 2004 05:36:43 -0000	1.2
  @@ -64,6 +64,10 @@
   {
       private final StringList data;
   
  +    private static final int LOCALNAME_OFFSET = 1;
  +    private static final int PREFIX_OFFSET = 2;
  +    private static final int VALUE_OFFSET = 3;
  +
       public AttributeHolder(int initial_capacity)
       {
           data = new StringList(4 * initial_capacity);
  @@ -111,15 +115,24 @@
       {
           assert (data.getSize() % 4) == 0;
   
  -        return data.get(3 + idx * 4);
  +        return data.get(VALUE_OFFSET + idx * 4);
       }
   
       public QName getAttributeName(int idx)
       {
           //TODO: consider caching these values...
  -        return new QName(getAttributeNamespace(idx),
  -                         getAttributeLocalName(idx),
  -                         getAttributePrefix(idx));
  +
  +        final String uri = getAttributeNamespace(idx);
  +        if (uri == null || uri.length() == 0) {
  +            return new QName(getAttributeLocalName(idx));
  +        } else {
  +            final String pfx = getAttributePrefix(idx);
  +            assert pfx != null;
  +            assert pfx.length() > 0;
  +            return new QName(uri,
  +                             getAttributeLocalName(idx),
  +                             pfx);
  +        }
       }
   
   
  @@ -134,14 +147,14 @@
       {
           assert (data.getSize() % 4) == 0;
   
  -        return data.get(1 + i * 4);
  +        return data.get(LOCALNAME_OFFSET + i * 4);
       }
   
       public String getAttributePrefix(int i)
       {
           assert (data.getSize() % 4) == 0;
   
  -        return data.get(2 + i * 4);
  +        return data.get(PREFIX_OFFSET + i * 4);
       }
   
       public boolean isAttributeSpecified(int i)
  
  
  

---------------------------------------------------------------------
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