text: Q:
  
  XSLT transformation to get Attribute Values
  
  I have the following XML file: 
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <DatDtl xmlns="http://ups.com/ttg/cache/country">
  <CnyDtl>
  <Cny TslLguCd="001" CnyCd="00" Cny2Cd="DNA" Cny3Cd="000" CnyNa="Data Not Available" CnyOflNa="Data Not Available" RecEffSttDt="2010-12-31" RecEffEndDt="2099-12-31" RecUdtTs="2012-07-27 15:35:08.352773"/>
  <Cny TslLguCd="001" CnyCd="96" Cny2Cd="OTH" Cny3Cd="996" CnyNa="Other" CnyOflNa="Other" RecEffSttDt="2010-12-31" RecEffEndDt="2099-12-31" RecUdtTs="2012-07-27 15:35:14.291605"/>
  </CnyDtl>
  </DatDtl>
  
  I Would like to convert it into a CSV file with just attribute values for CnyCd and CnyNa. I have following XSLT written to extract these two values:
  <
  
  ?xml version="1.0" encoding="ISO-8859-1"?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
           <xsl:for-each select="CnyDtl/Cny">
           <xsl:value-of select="@CnyNa"/>
  <xsl:value-of select="@CnyCd"/>
           </xsl:for-each>
          </xsl:template>
      </xsl:stylesheet>
  
  But I always get errors. What would be the correct XSLT transformation for this ? 
  
  A:
  
  First of all in your stylesheet you forgot the mention the root element <DatDtl>. Also don't forget to declare the namespace into your stylesheet.
  If you use the following XSLT 1.0 stylesheet:
  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mypref="http://ups.com/ttg/cache/country">
      <xsl:output method="text" />
  
      <xsl:variable name="FS"> <!-- Field seperator -->
          <xsl:text>;</xsl:text>
      </xsl:variable>
      <xsl:variable name="LT"> <!-- Line terminator -->
          <xsl:text>&#13;</xsl:text>
      </xsl:variable>
  
      <xsl:template match="/mypref:DatDtl">
          <xsl:for-each select="mypref:CnyDtl/mypref:Cny">
              <xsl:value-of select="@CnyNa"/>
              <xsl:value-of select=" $FS" />
              <xsl:value-of select="@CnyCd"/>
              <xsl:value-of select="$LT" />
          </xsl:for-each>
      </xsl:template>
  </xsl:stylesheet>
  
  It will give the following output:
  Data Not Available;00
  Other;96
  
  