XPath statement from document

K

Keith Davies

Hi All,

I've got a document containing a internal lookups (I want to show a
relationship hierarchy, starting at an arbitrary point, or series of
points).

It's easy if I know what item IDs I want to refer to during processing,
I can put in a @refid, @refids, or child elements listing the IDs to
process. No big deal. I'd *rather*, however, be able to specify an
XPath and have that resolved during transformation.


<show-tree refid='some-id' />

easy

<show-tree refids='some-id another-id' />
<show-tree>
<ref refid='some-id' />
<ref refid='another-id' />
</show-tree>

also easy.

<show-tree xpath='//element[type="some-type"]' />

I can't figure out. Ideally, something like

<xsl:template match='show-tree'>
<xsl:variable name='nodes' select='{@xpath}' />
<!-- do stuff with nodes -->
</xsl:template>

would be lovely, but select doesn't seem to like this.

I'm using Saxon for my transformations. I'm willing to use extensions,
though I'd rather not... but I'll accept expediency over purity.

Can anyone please provide some illumination or answers? I probably
*can* build a selection mechanism into my schema, but XPath is made for
this sort of thing; I'd like to be able to it rather than some ad hoc
construction if I can.


Thank you,
Keith
 
K

Keith Davies

I've got a document containing a internal lookups (I want to show a
relationship hierarchy, starting at an arbitrary point, or series of
points).

It's easy if I know what item IDs I want to refer to during processing,
I can put in a @refid, @refids, or child elements listing the IDs to
process. No big deal. I'd *rather*, however, be able to specify an
XPath and have that resolved during transformation.

<xsl:template match='show-tree'>
<xsl:variable name='nodes' select='{@xpath}' />
<!-- do stuff with nodes -->
</xsl:template>

would be lovely, but select doesn't seem to like this.

<xsl:template match='show-tree'>
<xsl:variable name='nodes' select='saxon:evaluation(@xpath)' />
<!-- do stuff with nodes -->
</xsl:template>

Slightly suboptimal, in that I have to use an extension. Seeing as XSLT
doesn't allow this sort of behavior, I guess I'll have to live with it.
Good enough.


Keith
 

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,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top