i ont le code XML suivant, qui est le résultat de runnig xslt:XSLT - activer la fonction XPath dans XSLT
<?xml version="1.0" encoding="UTF-8"?>
<toc xmlns:fn="http://www.w3.org/2004/07/xpath-functions" label="Sample Table of Contents">
<topic label="Title1" href="Ref1#ref1">
<topic label="Title 2" href="Ref2#ref2">
<topic label="Title3" href="Ref3#ref3"/>
<topic label="Title4" href="Ref4#ref4"/>
</topic>
<topic label="Title5" href="Ref5#ref5"/>
</topic>
<topic label="Title6" href="Ref6#ref6"/>
</toc>
et XSLT suivante qui produit ce xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="D:\Documents and Settings\oshecht\Desktop\XSL\Copy of toc.xml"?>
<?altova_samplexml D:\Documents and Settings\oshecht\Desktop\XSL\Copy of toc.xml?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2004/07/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="BODY">
<toc label="Sample Table of Contents">
<xsl:apply-templates select="UL/LI/OBJECT"/>
</toc>
</xsl:template>
<xsl:template match="OBJECT">
<topic label="{param[@name='Name']/@value}" href="{param[@name='Local']/@value}">
<xsl:apply-templates select="following-sibling::UL/LI/OBJECT"/>
</topic>
</xsl:template>
</xsl:stylesheet>
je veux que dans le fichier XML de sortie, je vais avoir dans:
follwing le:
- la même ligne, mais au lieu de href = "Ref1 # ref1" Souhaitée:
href = "Ref1" - éliminer tout après "#"
je sais au sujet de la sous-chaîne-avant que la fonction (Ref1 # ref1, '#') mais comment puis-je l'activer depuis mon XSLT?
pouvez-vous s'il vous plaît aviser?
cela a été fait résolu dans les commentaires à votre question initiale - pourquoi demander à nouveau? http://stackoverflow.com/questions/1553575/xslt-how-to-parse-xml-with-recursive-elements-to-eclipse-toc-xml/1553615#1553615 – Tomalak
J'ai ajouté une question ci-dessous la réponse ... la syntaxe n'a pas fonctionné, je un hetting "xpath invalide" – orly