Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] new Element("white space issue");

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Johan Strandberg <johan AT acm.org>
  • To: Luke P Immes <lpimmes AT multisegment.com>
  • Cc: xom mailing list <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] new Element("white space issue");
  • Date: Wed, 10 Sep 2003 23:46:56 -0000

Easy answer. You can't have whitespace in an element name:


From the XML standard, section 2.3
http://www.w3.org/TR/REC-xml#sec-common-syn

[Definition: A Name is a token beginning with a letter or one of
a few punctuation characters, and continuing with letters,
digits, hyphens, underscores, colons, or full stops, together
known as name characters.] Names beginning with the string
"xml", or any string which would match (('X'|'x') ('M'|'m')
('L'|'l')), are reserved for standardization in this or future
versions of this specification.]


An even simpler answer might be to think about how your element would
have looked:


<Company prospects name="foo">
Random text
</Company prospects>


How would you know that 'propsects' belonged to 'Company'? I.e., if you
allow whitespace in Names, then it might as well have been an element
called 'Company' with an attribute 'prospects name', right?

Just use a hyphen or underscore and you, XOM, and your parser will all
be happy.


<Company-prospects name="foo">
Random text
</Company-prospects>


--j



On Wed, 2003-09-10 at 16:08, Luke P Immes wrote:

> Members,
>
> I thank the development team for XOM. So far, I am pleased with it.
> Fortunately, it works with Unicode just fine.
> My question involves white space in an Element name. If I have
>
> new Element("Company prospects"); // or whatever string you wish
>
> I get the following runtime exception:
> nu.xom.IllegalNameException: XML names cannot contain the
> character " ".
>
> What is the best way to handle this? CData section? (I tried this as
> well without success).
> It is crucial that I have at least 1 char = space, in the element names.
> If it is not possible, then state this fact.
>
> Any help would be appreciated.
>
> Sincerely,
>
> Multisegment, Inc.
> C/O Luke P. Immes, President
> 20 Williamsburg Court, suite 14
> Shrewsbury, MA 01545
>
> http://www.multisegment.com
> lpi AT multisegment.com
>
> 508 579 2683 (cell)
> 508 845 5960 (voice)
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>




Archive powered by MHonArc 2.6.24.

Top of Page