You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gerhard Hipfinger <ge...@openforce.at> on 2002/05/10 21:14:18 UTC
xslt question
Hi!
I have the follwing xml file
<page>
<article>
<header>foo</header>
<leadin>bar</leadin>
</article>
<form>
<text name="/page/article/header" size="60"/>
</form>
</page>
and here some xslt snippets:
<xsl:template match="text">
<input type="text" name="{@name}" size="{@size}">
<xsl:attribute name="value"><xsl:value-of
select="@name"/></xsl:attribute>
</input><br />
</xsl:template>
then the output of the value field is "/page/article/header"
What I want is the content of page/article/header in the value field.
When I use this
<input type="text" name="{@name}" size="{@size}">
<xsl:attribute name="value"><xsl:value-of
select="/page/article/header"/></xsl:attribute>
</input><br />
I get exactly what I want. value field contains "foo"
Is it possible to get the content of a subnode in such a way? Have
someone another solution for this kind of problem?
Thanks,
Gerhard
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: xslt question
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Gerhard Hipfinger wrote:
...
XSLT questions are best asked on the XSL list, for some
obvious reasons.
http://www.mulberrytech.com/xsl/xsl-list/
> <text name="/page/article/header" size="60"/>
...
> <input type="text" name="{@name}" size="{@size}">
> <xsl:attribute name="value"><xsl:value-of select="@name"/></xsl:attribute>
...
> then the output of the value field is "/page/article/header"
You get what you ask for: the content of the @name attribute.
The processor won't interpret it as an XPath and evaluate it
again just because it looks like a good idea to you. There is
nothing magic about using xsl:attribute.
> Is it possible to get the content of a subnode in such a way?
Not in standard XSLT. Most processors have an extension function
called evaluate() or something similar, which takes a string as
parameter and evaulates the string as XPath expression:
<input type="text" name="{@name} value="{xx:evaluate(@name)}" size="{@size}">
Consult the manual of your processor for the details. This will
make your style sheet non-portable. Therefore better yet:
> Have
> someone another solution for this kind of problem?
You should use names/ids for crossreferences in you XML instead of
XPath expressions:
<page>
<article>
<header id="id1">foo</header>
<leadin>bar</leadin>
</article>
<form>
<text name="id1" size="60"/>
</form>
</page>
Use in XSL:
<xsl:key name="value" match="*" use="@id"/>
...
<input type="text" name="{@name} value="{key('value',@name)}" size="{@size}">
If you are using XForms, well, you're stuck with evaluate().
J.Pietschmann
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: xslt question
Posted by Ivelin Ivanov <iv...@apache.org>.
Have you looked at XMLForm?
http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/src/scratchpad/webapp/mount/xm
lform/
----- Original Message -----
From: "Gerhard Hipfinger" <ge...@openforce.at>
To: <co...@xml.apache.org>
Sent: Friday, May 10, 2002 2:14 PM
Subject: xslt question
> Hi!
>
> I have the follwing xml file
>
> <page>
> <article>
> <header>foo</header>
> <leadin>bar</leadin>
> </article>
>
> <form>
> <text name="/page/article/header" size="60"/>
> </form>
> </page>
>
>
> and here some xslt snippets:
>
> <xsl:template match="text">
> <input type="text" name="{@name}" size="{@size}">
> <xsl:attribute name="value"><xsl:value-of
> select="@name"/></xsl:attribute>
> </input><br />
> </xsl:template>
>
> then the output of the value field is "/page/article/header"
>
> What I want is the content of page/article/header in the value field.
> When I use this
>
> <input type="text" name="{@name}" size="{@size}">
> <xsl:attribute name="value"><xsl:value-of
> select="/page/article/header"/></xsl:attribute>
> </input><br />
>
> I get exactly what I want. value field contains "foo"
>
> Is it possible to get the content of a subnode in such a way? Have
> someone another solution for this kind of problem?
>
> Thanks,
> Gerhard
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>