Subject: Re: [xsl] Best way to represent an item and its context? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Thu, 15 Sep 2011 13:06:22 -0400 |
Hi Folks,
Consider this XML document:
<?xml version="1.0"?> <Book> <title>GML</title> <author>Ron Lake</author> <date>2004</date> </Book>
Suppose that while processing that XML document I get to the author element:
<author>Ron Lake</author>
I want to store this element and its context in a variable. The context of author is the entire document.
So I want a function that takes as input the author element and the Book element and returns a representation of the element and its context:
I have various functions which operate on that Item-in-Context variable. For example, one function returns the item's parent:
parent :: Item-in-Context -> Item
<xsl:function name="f:parent"> <xsl:param name="item"/> <xsl:sequence select="$item/.."/> </xsl:function>
Here I invoke the parent function and store the result into a second variable:
<xsl:template match="/">
<xsl:variable name="v1" select="f:item-in-context(Book/author, Book)" />
<xsl:variable name="v2" select="f:parent($v1)" />
</xsl:template>
What's the best way to represent an item and its context?
<xsl:variable name="v1" select="Book/author"/> <xsl:variable name="v2" select="$v1/.."/>
-- Contact us for world-wide XML consulting and instructor-led training Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Best way to represent an item, Costello, Roger L. | Thread | Re: [xsl] Best way to represent an , Martin Honnen |
[xsl] Best way to represent an item, Costello, Roger L. | Date | Re: [xsl] Best way to represent an , Martin Honnen |
Month |