tags:

views:

50

answers:

3

I have this XML:

 <?xml version="1.0" encoding="utf-8" ?>
 <IMPORT mode="FULL">
    ....
 </IMPORT>

I'm trying to convert it with the following XSLT stylesheet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  <xsl:template match="/">
    <xsl:element name="import">
      <xsl:attribute name="mode">
        <xsl:value-of select="@mode"/>
      </xsl:attribute>
           ....
      </xsl:element>
  </xsl:template>

My problem is that the following line doesn't seem to work:

<xsl:value-of select="@mode"/>

As I only get

<import mode="">

instead of the expected:

<import mode="FULL">

Any clues ?

+1  A: 

Try to use <xsl:value-of select="IMPORT/@mode"/>

Nerrio
thank you all for your answers
+4  A: 

You're not actually on the IMPORT element.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  <xsl:template match="/">
    <xsl:apply-templates select="IMPORT"/>
  </xsl:template>
  <xsl:template match="IMPORT">
    <xsl:element name="import">
      <xsl:attribute name="mode">
        <xsl:value-of select="@mode"/>
      </xsl:attribute>
       ....      
    </xsl:element>
  </xsl:template>
Lucero
A: 

Try this:

<xsl:template match="IMPORT">
    <xsl:element name="import">
     <xsl:attribute name="mode">
      <xsl:value-of select="@mode"/>
      </xsl:attribute>
    </xsl:element>
</xsl:template>
Manish