[jdom-interest] PI.getValue() returning "" [eg]

Jason Hunter jhunter at collab.net
Wed Mar 14 13:19:31 PST 2001


I meant getValue("quux").

How we've been doing it so far is that if the PI data is formatted like
an element attribute list, then it's available as name/value pairs as
well as a data string.  If it doesn't follow that format, then it's
available only as a data string.  Examples of failure include:

<?pi foo='bar" bax='hi'?>
<?pi foo=bar?>
<?pi x y z foo='bar'?>
<?pi a b c d e = ' k l m n o " p ' ?>

For each of these, I'd argue PI should detect the malformedness and not
try to extract name/value information from the noise.  The alternative
is to have the parser forgive errors, but that opens a nasty can of
worms, especially considering we have to spec behavior in detail for the
JSR.  Like for the top one should you get foo equal to 'bar" bax=' or
should you get bax equal to 'hi'?  I think we have better things to
worry about and we just say if there's malformatting we stop.

-jh-

Wesley Biggs wrote:
> 
> Jason,
> 
> I'm confused by your example.  In <?targ quux="a" bar?>, pi.getValue("quux")
> should be "a", right?  You meant what should pi.getValue("bar") give you,
> I'll assume.
> 
> It looks like a classic tri-state problem.
> 
> Is it important to be able to distinguish
> <?targ quux="a" bar?>
> from
> <?targ quux="a" bar=""?>
> ?
> 
> If not, both should return "".  If it is important, how about adding a
> PI.hasName(name) method (or something similar) and let the former case
> return null.
> 
> Wes
> 
> -----Original Message-----
> From: Steven D. Keens [mailto:skeens at planetfred.com]
> Sent: Wednesday, March 14, 2001 6:35 AM
> To: jdom-interest
> Subject: RE: [jdom-interest] PI.getValue() returning "" [eg]
> 
> Also, in your example
> 
> <?targ quux="a" bar?>
> 
> If pi.getValue("quux") returned null then we
> wouldn't be able to distinguish it from
> pi.getValue("bar").  If it's a key-value pair
> then we should be allowed to treat it as an
> attribute.  If it isn't then returning null
> can indicate that we don't have an attribute
> like data.
> 
> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Jason Hunter
> Sent: Wednesday, March 14, 2001 06:59
> To: JDOM Interest
> Subject: [jdom-interest] PI.getValue() returning "" [eg]
> 
> Quick poll.  As many of you know, ProcessingInstruction can parse the PI
> data and make it available like attributes as a convenience since that's
> so commonly how PI data is written.  I'd like to make sure the end cases
> behave correctly.
> 
> Given the PI:
> 
> <?targ foo="a" bar=""?>
> 
> pi.getValue("foo") returns "a"
> pi.getValue("bar") returns ""
> What should pi.getValue("bogus") return?
> 
> And given the PI:
> 
> <?targ quux="a" bar?>
> 
> What should pi.getValue("quux") return?
> 
> Current answers are "" and "".  I'm wondering if they should be null and
> null to better match Attribute behavior.  Before we change it, I'm
> looking for logical reasons why it's best one way or the other.
> 
> FYI, I don't want pi.getValue("quux") to return "a" because I think if
> the PI's data doesn't parse completely as attributes then it shouldn't
> be treated as attributes.  To do anything more fancy has the potential
> to appear nondeterministic.
> 
> -jh-
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t.com
> 
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
> t.com
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com



More information about the jdom-interest mailing list