Originariamente inviato da Polley
non è che prelevi il contenuto da un'altro file esterno utilizzando document() ?
e nell'altro xslt cè xmlns ?
nessun document() e il mio xslt da trasformare semplicemente formatta una tabella (sorgente della tabella è un file XML)
SORGENTE
--------------------------------------------
codice:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:template match="/">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="DATA">
<tr>
<th>Capo1 - Valore1</th>
<th>Capo1 - Valore2</th>
<th>Capo1 - Valore3</th>
<th>Capo2 - Valore1</th>
</tr>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="LINE">
<tr>
<td align="left" width="100">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of select="format-number(C1V1, '0.00')"/>
</td>
<td>
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if test="C1V2!=0">
<xsl:value-of select="substring(C1V2,7,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(C1V2,5,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(C1V2,1,4)"/>
</xsl:if>
</td>
<td align="center" width="80px">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if test="C1V3!=0">
<xsl:variable name="from" select="string-length(C1V3)-8"/>
<xsl:value-of select="substring(C1V3,$from,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+2,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+4,2)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(C1V3,$from+6,3)"/>
</xsl:if>
</td>
<td align="center" width="80px">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if test="C1V3!=0">
<xsl:variable name="from" select="string-length(C1V3)-7"/>
<xsl:value-of select="substring(C1V3,$from,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+2,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+4,2)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(C1V3,$from+6,2)"/>
</xsl:if>
</td>
<td align="left" width="100">
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of select="C2V1"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
CONVERTER
---------------------------------------------------------
codice:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:strip-space elements="node()"/>
<xsl:template match="xsl:template">
<xsl:if test="@match='DATA'">
<xsl:text>/** HEADER **/</xsl:text>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="tr/th"/>
</xsl:if>
<xsl:if test="@match='LINE'">
<xsl:text>/** BODY **/</xsl:text>
<xsl:text>
</xsl:text>
<xsl:apply-templates select="tr/td"/>
</xsl:if>
</xsl:template>
<xsl:template match="tr/th">
<th><xsl:value-of select="."/></th>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="tr/td">
<xsl:apply-templates select="xsl:if"/>
<xsl:apply-templates select="xsl:value-of"/>
</xsl:template>
<xsl:template match="xsl:value-of">
<xsl:choose>
<xsl:when test="@select[contains(.,'format-number' )]">Field: <xsl:value-of
select="substring-before(substring-after(@select,'format-number('),',')"/>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>Field: <xsl:value-of select="@select"/>
<xsl:text>
</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="../."/>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="xsl:if">Field: <xsl:value-of disable-output-escaping="yes" select="substring-before(@test,'!')"/>
<xsl:text>
</xsl:text>
<xsl:copy-of select="../."/>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
OUTPUT
---------------------------------------------------
codice:
/** HEADER **/
<th xmlns:xs="http://www.w3.org/2001/XMLSchema">Capo1 - Valore1</th>
<th>Capo1 - Valore2</th>
<th>Capo1 - Valore3</th>
<th>Capo2 - Valore1</th>
/** BODY **/
Field: C1V1
<td align="left" width="100"><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="format-number(C1V1, '0.00')"/></td>
Field: C1V2
<td><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if xmlns:xsl="http://www.w3.org/1999/XSL/Transform" test="C1V2!=0"><xsl:value-of select="substring(C1V2,7,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(C1V2,5,2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(C1V2,1,4)"/>
</xsl:if></td>
Field: C1V3
<td align="center" width="80px"><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if xmlns:xsl="http://www.w3.org/1999/XSL/Transform" test="C1V3!=0"><xsl:variable name="from" select="string-length(C1V3)-8"/>
<xsl:value-of select="substring(C1V3,$from,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+2,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+4,2)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(C1V3,$from+6,3)"/>
</xsl:if></td>
Field: C1V3
<td align="center" width="80px"><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:if xmlns:xsl="http://www.w3.org/1999/XSL/Transform" test="C1V3!=0"><xsl:variable name="from" select="string-length(C1V3)-7"/>
<xsl:value-of select="substring(C1V3,$from,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+2,2)"/>
<xsl:text>:</xsl:text>
<xsl:value-of select="substring(C1V3,$from+4,2)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="substring(C1V3,$from+6,2)"/>
</xsl:if></td>
Field: C2V1
<td align="left" width="100"><xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform" disable-output-escaping="yes">&nbsp;</xsl:text>
<xsl:value-of xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="C2V1"/></td>