Altova Mailing List Archives


Re: [xsl] Best way to represent an item and its context?

From: Michael Kay <mike@--------.--->
To: xsl-list@-----.------------.---
Date: 9/15/2011 5:12:00 PM
In the XPath 2.0 data model there are very limited ways to represent 
complex or composite information of this kind. You could use a sequence 
with two items, attaching conventional meanings to the two items, but 
it's not very satisfactory.

In XPath 3.0 with higher-order functions you have a lot more 
flexibility. We're trying to get support for maps into the language too, 
so you will be able to return a map with two components, "item" and 
"context" (both of which might be composite values represented by 
further maps). At present we've defined this for XSLT 3.0 but there's 
strong resistance to putting it into XQuery 3.0, which is creating some 
tensions.

Michael Kay
Saxonica

On 15/09/2011 17:47, Costello, Roger L. wrote:
> 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:
>
> item-in-context :: Item ->  Context ->  Item-in-Context
>
> Read as: "The function item-in-context has two arguments -- an item (element) and a context -- and it returns a representation of the element and its context."
>
> Here I invoke that function and store the result into a variable:
>
> <xsl:template match="/">
>
>        <xsl:variable name="v1" select="f:item-in-context(Book/author, Book)" />
>
> </xsl:template>
>
> 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
>
> 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?
>
> /Roger
>
> --~------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail:<mailto:xsl-list-unsubscribe@l...>
> --~--
>
>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.