[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Lookup (?)
Subject: Re: [xsl] Lookup (?) From: "Perry Molendijk" <perry@xxxxxxxxxxxxxx> Date: Tue, 19 Feb 2002 12:08:36 +0800 |
Infexions (WA) Pty LtdHi, There is a Saxon extension saxon:evaluate(string) you should get the result using something like this: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <html> <head> <title>saxon:evaluate()</title> </head> <body> <form> <xsl:apply-templates select="/imb/form/input"/> </form> </body> </html> </xsl:template> <xsl:template match="input"> <xsl:variable name="evalXPath" select="saxon:evaluate(@ref)"/> <xsl:value-of select="caption"/> <xsl:text>: </xsl:text> <input type="text" name="{@ref}" value="{$evalXPath}"/> <br/> </xsl:template> </xsl:stylesheet> you do loose portability with this approach. You could modify your xml and xsl to do something like this: <imb> <form form-id="1"> <input widget-id="1" name="firstName"> <caption>First name</caption> </input> <input widget-id="2" name="lastName"> <caption>Last name</caption> </input> </form> <!-- form-ref-id = form-id --> <data form-ref-id="1"> <user> <!-- widget-ref-id = widget-id --> <firstname widget-ref-id="1">Jix</firstname> <lastname widget-ref-id="2">Jacoby</lastname> </user> </data> </imb> <xsl:stylesheet .... .... <xsl:template match="input"> <xsl:variable name="formWidgetId" select="@form-widget-id"/> <input type="text" name="{@name}"> <xsl:attribute name="value"> <xsl:value-of select="//data/user/*[@widget-ref-id = $formWidgetId]"/> </xsl:attribute> </input> </xsl:template> ----- Original Message ----- From: "Kurt George Gjerde" <kurt.gjerde@xxxxxxxxxxxxxxxxx> To: <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, February 18, 2002 7:46 PM Subject: [xsl] Lookup (?) > Hi, > > Is it possible in xslt to get hold of the content (value) of a node which > path is contained in an attribute of another node?? > > I have an xml file like this: > > <!-- this is a quick-and-dirty xml-form thing (not xforms) > just as an example --> > > <imb> > <form> > <input ref="//data/user/firstname"> > <caption>First name</caption> > </input> > <input ref="//data/user/lastname"> > <caption>Last name</caption> > </input> > </form> > > <data> > <user> > <firstname>Jix</firstname> > <lastname>Jacoby</lastname> > </user> > </data> > </imb> > > Which needs to come out as something like this: > > <p> > First name: <input name="//data/user/firstname" value="Jix"/> > </p><p> > Last name: <input name="//data/user/lastname" value="Jacoby"/> > </p> > > Haven't found any way of doing this. Is it possible with XSLT or by using > some Saxon extensions? > > > Thanks, > -Kurt. > __________ > kurt george gjerde <kurt.gjerde@xxxxxxxxxxxx> > intermedia uib, university of bergen > > use Perl; > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Lookup (?), Carsten Klein | Thread | [xsl] passing a value from HtML to , 林 子芯 |
Re: [xsl] duplicate id's, Perry Molendijk | Date | [xsl] Attribute name clashes???????, hnorris |
Month |