Thursday, April 11, 2013

XSL - function template return multiples values

Template - return a Point(x,y)

<xsl:template name="getRealPoint">
        <xsl:param name="x"/>
        <xsl:param name="y"/>

        <xsl:param name="rate"/>
        <point>
            <x><xsl:value-of select="$x div $rate"></xsl:value-of></x>
            <y><xsl:value-of select="$y div $rate"></xsl:value-of></y>
        </point>
</xsl:template>

Result


<point>
   <x>10</count>
   <y>1</min>
</point>
 

Template - getType

XML Data - enclosure-types.xml

 
<?xml version="1.0" encoding="UTF-8"?>
<enclosure_types>
<type name="EXTERNALLOADBEARINGWALL">
<color>#7F3300</color>
<width>1</width>
</type>

<type name="GROUNDFLOOR">
<color>#7F33FF</color>
<width>1</width>
</type>

<type name="EXTERNALADIABATICWALL">
<color>#FF0033</color>
<width>1</width>
</type>
</enclosure_types>
 

XSL

<xsl:variable name="ENCLOSURETYPE"
select="document('enclosure-types.xml')/enclosure_types/type" /> 

<xsl:template name="getTypesAttributes">
 <xsl:param name="enclosureType" />
 <xsl:value-of name="width" select='$ENCLOSURETYPE[@name=($enclosureType)]/width'>
 <xsl:value-of name="color" select='$ENCLOSURETYPE[@name=($enclosureType)]/color'> 
</xsl:template>
2:51 PMtech-mashup