views:

113

answers:

1
<data>
<Attributes>
 <Attribute name='somethingelse' value='blah'/>
 <Attribute name='forms'>
    <List>
      <String>xform</String>
      <String>yform</String>
    </List>
  </Attribute>
</Attributes>
</data>

I am already parsing the xslt at Attributes level, so I can get the value blah by just doing <xsl:value-of select="Attribute[@name='somethingelse']/attribute::value"/>

how do i do a select for the forms which has 2 strings xform and yform. I would like to get xform and yform on a same line. From other thread someone gave me the following code:

<xsl:template match="/">
  <xsl:for-each select="//String">
<xsl:value-of select="."/><xsl:if test="not(position() = last())">|</xsl:if>
  </xsl:for-each>
  </xsl:template>

I am not sure how to put it all together.My goal is to have a output like:

blah,xform|yform

+1  A: 

Not sure if I got your question right, but I guess that should output what you want:

<xsl:template match="/">
  <xsl:apply-templates select="//Attributes"/>
</xsl:template>

<xsl:template match="Attributes">
  <xsl:value-of select="Attribute[@name='somethingelse']/@value"/>
  <xsl:text>,</xsl:text>
  <xsl:for-each select="Attribute[@name='forms']/List/String">
    <xsl:value-of select="."/>
    <xsl:if test="position() != last()">|</xsl:if>
  </xsl:for-each>
</xsl:template>
Lucero