> The only real difference is that in the BY_NAME case, a call to
> propertyIndex.lastIndexOf(":") finds the last occurrence of ":" in the
> property name. I use lastIndexOf because some of the properties I am
> interested in querying, from Microsoft Exchange, have a
> prefix of the form:
>
> urn:schemas:httpmail:fromemail
>
> So obviously looking for the first occurrence of the colon
> would not work in
> this case. If no colon can be found in the string the
> namespace is assumed
> to be DAV: and printer.writeElement("D", propertyName,
> XMLPrinter.NO_CONTENT) is called, making use of the fact that the DAV:
> namespace was declared as part of the <propfind> element.
>
> If an occurrence of ":" is found the property name is
> separated into its
> prefix and local name parts and printer.writeElement("ZZ",
> prefix, local,
> XMLPrinter.NO_CONTENT) is called defining a namespace "ZZ"
> scoped to this
> element.
>
> Everything works, but there is one thing that I'm wondering
> about. Defining
> a namespace for each non DAV: property element is redundant
> and leads to
> increased network traffic if a large group of properties
> share the same non
> DAV: namespace. A much more elegant solution would be to preparse the
> propertyNames Vector and generate a hash containing unique
> namespaces and
> abbreviations to represent those namespaces in XML. A new
> writeElement
> method could then be added to XMLWriter which took a hash as
> a parameter and
> declared all of the namespaces associated with the property
> names within the
> <propfind> element.
>
> Would this be a worthwhile improvement?
One remark, not all namespaces are ending with ":", for example the slide
namespace is
defined as "http://jakarta.apache.org/slide/".
I would split on the last character that isn't a Letter | Digit | '.' | '-'
| '_'
Preparsing the namespaces is a good idea, reducing network traffic is always
good
and xml already adds a lot of overhead.
Dirk