|
Subject: Re: how do indirection in value-of or select? From: "James Tauber" <jtauber@xxxxxxxxxxx> Date: Sat, 27 Feb 1999 18:00:50 +0800 |
>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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| how do indirection in value-of or s, Mark D. Anderson | Thread | Re: how do indirection in value-of , Michael Koehrsen |
| Re: is it just me?, James Tauber | Date | Re: how do indirection in value-of , Michael Koehrsen |
| Month |