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

Re: Lookup (?)

Subject: Re: Lookup (?)
From: "Perry Molendijk" <perry@xxxxxxxxxxxxxx>
Date: Tue, 19 Feb 2002 12:08:36 +0800
xslt lookup ref
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:  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

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.