OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] DESIGN PROPOSAL: Java XMLIterator

[ Lists Home | Date Index | Thread Index ]

At 5:11 PM -0500 12/17/01, John Cowan wrote:


>package org.ccil.cowan.iter;
>public interface XMLIterator
>	extends java.util.Iterator {
>

I know this is how Java iterator are implemented but it really bugs 
me when you you're returning an XMLNode, but the methods are only 
declared to return java.lang.Object. Frankly, this bugs me so much I 
wouldn't extend java.util.Iterator

>// Node types: legal return values of XMLNode.getType method
>public static int END = 0;
>public static int ELEMENT = 1;
>public static int ATTRIBUTE = 2;
>public static int SKIPPED_ENTITY = 3;
>public static int END_ELEMENT = 4;
>public static int PI = 5;
>
>// Attribute types: legal return values of getAttributeType method
>public static int CDATA = 0;
>public static int ID = 1;
>public static int IDREF = 2;
>public static int IDREFS = 3;
>public static int NMTOKEN = 4;	// also used for enumerations
>public static int NMTOKENS = 5;
>public static int ENTITY = 6;
>public static int ENTITIES = 7;
>public static int NOTATION = 8;

Integer type constants are error-prone. Use type-safe enums instead.

>
>
>package org.ccil.cowan.iter;
>public interface XMLNode {
>
>// If the current node is an ELEMENT or ATTRIBUTE node,
>// and QName information is available, return it
>public string getQName();
>
i
Java names shouldn't be abbreviated. getQualfiedName() would be better

>// If the current node is an ELEMENT or ATTRIBUTE node, and
>// local name information is available, return it;
>// if the current node is a PI node, return the target;
>// if the current node is a SKIPPED_ENTITY node,
>// return the entity name
>public string getLocalName();
>

and if its something else like a comment? return null? return 
#comment? This should be documented.

>// If the current node is an ELEMENT node,
>// return an Attributes object containing the attributes
>public org.xml.sax.Attributes getAttributes();
>

and if it's not?

>// If the current node is an ELEMENT node,
>//   return all text content up to the next tag;
>// if the current node is an ATTRIBUTE node,
>//   return the normalized attribute value;
>// if the current node is an END_ELEMENT node,
>//   return all text content up to the next tag;

Is this the text before or after the end-tag?

>// if the current node is a PI node,
>//   return the content of the PI
>public string getValue();
>

-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|              http://www.ibiblio.org/xml/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.ibiblio.org/xml/     |
+----------------------------------+---------------------------------+




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS