[jdom-interest] Mailing List for JDOM

Brett McLaughlin brett.mclaughlin at lutris.com
Thu Sep 14 08:55:30 PDT 2000

The list is fixed... sorry I forgot to get back to you on that.

Hey, isn't your bug in getAttribute().getValue():

I have simple XML file with elements like this:

<resource key="REGEX" value="m/[a-z].*\\W+/s" />

when I read it in and call Element.getAttributeValue("value"), I get
as the string:

where the original has an escaped "\\" in it:

Any idea what gives?

Isn't this simply a case of Java doing the right thing? The backslash
("\") is an escape character, which means that anytime it goes into a
String, it essentially gets turned into an escape sequence. So "\\" is a
way to output "\" in a program. I think if you want "\\" in your output,
you /should/ have to enter in "\\\\" as the value, at least in a Java
program. If we did ensure that "\" wasn't treated as an escape value,
but instead as a literal, I'm not sure how you would enter in actual
escape characters (like \n, \r, etc.). Granted, I'm not sure you would
/want/ to in an attribute value, but I know you would in element values.
So do we want the value of an Attribute to be set using different rules
than an Element? I'm not sure about this.

The more I think about it, the more I think this isn't a bug, but just
the way Java handles String values and escape sequences. Let me know
what you think.


Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 

More information about the jdom-interest mailing list