From: Gilles Grandon (gilles.grandon@mondeca.com)
Date: 11/09/2002 - 09:20
bonjour a tous ,
mon document principal:
<section>
<section>
<include
xlink:href="monDoc1.xml"/>
<section>
<include
xlink:href="monDoc1.xml"/>
</section>
</section>
<section>
<include
xlink:href="monDoc2.xml"/>
</section>
</section>
mon document externe:
<section
xmlns:xlink="http://www.w3.org
/1999/xlink">
<title>NAME</title>
<keyword
xml:lang="fr">ghjjgh</keyword>
<section>
<title>un titre
ajouté</title>
<para>blabla</para>
</section>
<section>
<title>Topics</title>
<related
xlink:href="topic_fr.xml">Topi
cs</related>
<para>mon para.</para>
</section>
</section>
je voudrais former un document
final XML ou les noeuds
<include> serait remplacé par
le jeu de noeud du fichier
externe (qui lui peut aussi
contenir <include>)
au moment ou le parser est en
train de lire le document
exterieur et qu'il rencontre
un noeud <section> , il
n'applique pas le
<xsl:apply-templates
select="section">.
1) qq pourrais me dire ce qui
ne va pas dans mon XSL
2) a t on le droit d'écrire :
document(/)/monNoeud ?
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1
999/XSL/Transform"
xmlns:xlink="http://www.w3.org
/1999/xlink" version="1.0">
<xsl:output version="1.0"
encoding="ISO-8859-1"
indent="yes"/>
<xsl:variable name="courant"
select="/"/>
<xsl:template
match="/section">
<section
xmlns:xlink="http://www.w3.org
/1999/xlink">
<xsl:for-each
select="child::*">
<xsl:choose>
<xsl:when
test="name()='include'">
<xsl:call-template
name="include">
<xsl:with-param name="url"
select="@xlink:href"/>
</xsl:call-template>
</xsl:when>
<xsl:when
test="name()='section'">
<xsl:apply-templates
select="section"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of
select="self::*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</section>
</xsl:template>
<!-- regle section -->
<xsl:template match="section">
<section>
<xsl:for-each
select="child::*">
<xsl:choose>
<xsl:when
test="name()='include'">
<xsl:call-template
name="include">
<xsl:with-param
name="url"
select="@xlink:href"/>
</xsl:call-template>
</xsl:when>
<xsl:when
test="name()='section'">
<xsl:apply-templates
select="section"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of
select="self::*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</section>
</xsl:template>
<!-- regle include -->
<xsl:template name="include">
<xsl:param name="url"/>
<xsl:for-each
select="document($url)/section
/child::*">
<xsl:choose>
<xsl:when
test="name()='include'">
<xsl:call-template
name="include">
<xsl:with-param
name="url"
select="@xlink:href"/>
</xsl:call-template>
</xsl:when>
<xsl:when
test="name()='section'">
<xsl:apply-templates
select="section"/>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of
select="self::*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
merci a ceux qui pourront
m'éclairer
gilles.
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Archive générée par hypermail 2.1.3 le 28/06/2004 - 11:06 UTC
webmaster@xmlfr.org
|