1 Reply Latest reply on Mar 14, 2008 12:11 AM by coffeedrinker56

    xmltranform  xsl issues

    Crazy_Tuna Level 1
      Hello, I have been tring to pull data from xml document using xmltransform. The xmltranform works and I am able to get data from the xml document, but having trouble when there are multiple data of the same nature. I can not pull the names or the Phone number. I am new to xml, so be gentle with me. The code I have here was gleaned from multiple websites. I have included the xml, xsl stylesheet code and the html output. Thanks for any help in advance. Craig
        • 1. Re: xmltranform  xsl issues
          It's easier to use params and additional templates... something like this:

          <xsl:template match="contact" >
          <!-- The values for the params are set in other templates -->
          <xsl:param name="fName" />
          <xsl:param name="lName" />
          <xsl:param name="emailAddr" />
          <xsl:for-each select="name">
          <xsl:call-template name="getName">
          <xsl:with-param name="fName" />
          <xsl:with-param name="lName" />
          Name: <xsl:value-of select="$fName"><xsl:text> </xsl:text><xsl:value-of select="$lName" /><br />

          <!-- You really don't need another template here, but you can use one -->
          <!-- It can be written: Email: <value-of select="email" /> but this is another demo -->
          <xsl:apply-templates select="email">
          <xsl:with-param name="emailAddr" />
          Email: <xsl:value-of select="$emailAddr" /><br />

          <!-- This template "fills" names dependent upon the "part" attibute -->
          <!-- Values set here are available to the template that called this one -->
          <xsl:template name="getName">
          <xsl:param name="fName" />
          <xsl:param name="lName" />
          <xsl:when test="@part='first'">
          <xsl:param name="fName" select="." />
          <xsl:param name="lName" select="." />

          <xsl:template match="email">
          <xsl:with-param name="emailAddr" select="." />