Florent Georges wrote:
BTW, I suggest you to take a look at "Literal Result Elements",
"Template Rules", and maybe the "Modified Identity Tranformation
Pattern".
It is not really explicit. Starting from your code:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="us-ascii" indent="yes"/>
<xsl:template match="/">
<xsl:element name="root" namespace="http://www.fo.com">
<xsl:for-each select="Text">
<xsl:element name="Text">
<xsl:element name="tag">
<xsl:value-of select="tag"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
"Literal Result Elements" let you write:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="us-ascii" indent="yes"/>
<xsl:template match="/">
<f:root xmlns:f="http://www.fo.com">
<xsl:for-each select="root/Text">
<Text>
<tag>
<xsl:value-of select="tag"/>
</tag>
</Text>
</xsl:for-each>
</f:root>
</xsl:template>
</xsl:stylesheet>
"Template Rules" let you write:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="us-ascii" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="root">
<f:root xmlns:f="http://www.fo.com">
<xsl:apply-templates/>
</f:root>
</xsl:template>
<xsl:template match="Text">
<Text>
<xsl:apply-templates select="tag"/>
</Text>
</xsl:template>
<xsl:template match="tag">
<tag>
<xsl:value-of select="tag"/>
</tag>
</xsl:template>
</xsl:stylesheet>
and "Modified Identity Tranformation Pattern" let you write:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="us-ascii" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<f:root xmlns:f="http://www.fo.com">
<xsl:apply-templates/>
</f:root>
</xsl:template>
<xsl:template match="Text">
<xsl:copy>
<xsl:apply-templates select="tag"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
or (depending on your real usage):
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"
encoding="us-ascii" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<f:root xmlns:f="http://www.fo.com">
<xsl:apply-templates/>
</f:root>
</xsl:template>
<xsl:template match="junk|junk2"/>
</xsl:stylesheet>
Regards,
--drkm
___________________________________________________________________________
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos
services préférés : vérifiez vos nouveaux mails, lancez vos recherches et
suivez l'actualité en temps réel.
Rendez-vous sur http://fr.yahoo.com/set
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--