This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Newbie to XSLT




>Basically, how do we store the "Cube 47" value in a variable, then use
>it to go back through the document and look for the size for "Cube 47"
>??? ) 

putting <x> ... </x> around your posted example to make it well formed:

bash-2.01$ xt size.xml size.xsl 
<?xml version="1.0" encoding="utf-8"?>
John has size 26 ft.
 bash-2.01$ 

You probably don't need a variable, I used on below to make 
the expression a bit easier to read.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0"
                >

<xsl:output method="xml" indent="yes"/>

<xsl:template match="x">
 <xsl:for-each select="instance[@name='pc']">
  <xsl:value-of select="value"/> has size <xsl:apply-templates select="."/>.
 </xsl:for-each>
</xsl:template>

<xsl:template match="instance[@name='pc']">
  <xsl:variable name="x" select="../instance[@type='Association']
         [reference[@antecedent='pc']/value[.=current()/value]]
         /reference[@dependent='location']/value"/>
  <xsl:value-of select="../instance[@name='location'][value=$x]/size"/>
</xsl:template>

</xsl:stylesheet>


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]