[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how do indirection in value-of or select?

Subject: Re: how do indirection in value-of or select?
From: "James Tauber" <jtauber@xxxxxxxxxxx>
Date: Sat, 27 Feb 1999 18:00:50 +0800
indirection xsl
>i'm willing to change the syntax of the xml if that helps,
>but it does seem like xsl should have some way to do this.
>macros? constants? producing elements that are then processed
>again by the processor? or can xsl just not do a join?


I *think* this is similar to what I've wanted to do for a while and have
raised on this list before.

As far as I can tell, what would solve my problem (and I think yours) is if
an EqualityExpr could take not just a Literal but a select pattern.

In other words,

Say I have a document:

    <a>
        <blist>
            <b n="foo"><bname>Foo</bname></b>
            <b n="bar"><bname>Bar</bname>/b>
        </blist>
        <clist>
            <c>
                <cname>c1</cname>
                <d>foo</d>
            </c>
            <c>
                <cname>c2</cname>
                <d>bar</d>
            </c>
            <c>
                <cname>c3</cname>
                <d>foo</d>
                <d>bar</d>
            </c>
        </clist>
    </a>

I would like to be able to say:

    <xsl:template match="/a/blist/b">
        <xsl:apply-templates select="name"/>
        <xsl:apply-templates select='/a/clist/c[d=@n]'/>
    </xsl:template>

but you can't say d=@n, only d="literal".

At present I use:

    <xsl:template match="/a/blist/b">
        <xsl:apply-templates select="name"/>
        <xsl:choose>
            <xsl:when test='.[@n="foo"]'>
                <xsl:apply-templates select='/a/clist/c[d="foo"]'/>
            </xsl:when>
            <xsl:when test='.[@n="bar"]'>
                <xsl:apply-templates select='/a/clist/c[d="bar"]'/>
            </xsl:when>
        </xsl:choose>
    </xsl:template>

which involves knowing about "foo" and "bar" in advance. Fortunately, what
*is* possible is automatic generation of the above template from the
original document. It works but I don't think it should have to be done that
way.

I *think* a solution to my problem will be a solution to yours and I think
the best solution is if XSL is modified so that an EqualityExpr can take not
just a Literal but a select pattern.

Comments anyone?

James



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.