Weird Results in XML

S

Sparky

Greetings:

I am getting a result via an XStream XML report that looks as follows:
<owner class="com.mrll.security.LoginVO" reference="../.."/> (Please
note the reference="../.." portion)

If you follow the "../.." you end up in the previous node where the
information I need is in the XML. Is there any w2ay to get this
information out of this file using XSL?

Thanks,
 
M

Martin Honnen

Sparky said:
I am getting a result via an XStream XML report that looks as follows:
<owner class="com.mrll.security.LoginVO" reference="../.."/> (Please
note the reference="../.." portion)

If you follow the "../.." you end up in the previous node where the
information I need is in the XML. Is there any w2ay to get this
information out of this file using XSL?

Well if you know that the reference is ../.. then you can use it as an
XPath expression in your XSLT stylesheet. However dynamic XPath
evaluation is not possible thus if you expect to take the reference
attribute value and construct an XPath expression from it then that does
not work with standard XSLT/XPath in one stylesheet. You could however
process the document using one XSLT stylesheet that creates a second
stylesheet, then you could apply that second stylesheet.
 
P

Pavel Lepin

Sparky said:
I am getting a result via an XStream XML report that looks
as follows: <owner class="com.mrll.security.LoginVO"
reference="../.."/> (Please note the reference="../.."
portion)

I would recommend investigating your XML provider to see
whether it would be possible to convince it to use
IDs/IDREFs for references instead of this abomination.
 
J

Joseph Kesselman

Martin said:
Well if you know that the reference is ../.. then you can use it as an
XPath expression in your XSLT stylesheet. However dynamic XPath
evaluation is not possible

Well, not with basic XSLT. The EXSLT extension library is available in
many XSLT processors, and one of its optional modules is dynamic XPath
evaluation... so that's worth checking.

If not, then I agree that "styling stylesheets" may be a good solution.
 
J

Joseph Kesselman

Pavel said:
I would recommend investigating your XML provider to see
whether it would be possible to convince it to use
IDs/IDREFs for references instead of this abomination.

I don't know that I'd call it an abomination... but yes, ID/IDREF (or
key/keyref if you're working with schemas) is a more common way of
referencing locations within a single document.
 
P

Pavel Lepin

Joseph Kesselman said:
I don't know that I'd call it an abomination... but yes,
ID/IDREF (or key/keyref if you're working with schemas) is
a more common way of referencing locations within a single
document.

Well, I'm thinking in terms of XSLT processing, as the OP
seemed to, - and we still don't have first-class XPath
expressions, even in XSLT2.

Besides, I think this particular application (using, as you
said, EXSLT for example) is a can of worms better left
unopened. For one thing, it's not humanly possible to
preserve the references of this kind if we're doing
anything non-trivial with the input document; while the
same task is largely a no-brainer using IDs/IDREFs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top