À l'aide de XSLT pour créer XSL-FO avec imbriqué gras/italique tags
Je suis de la création du fichier xslt, qui devrait convertir mon xml en xsl-fo.
XML est quelque chose comme ça:
<doc>
<par>
<point>
<text>some text</text>
</point>
</par>
</doc>
Bien sûr, il y a beaucoup de paragraphes et de points dans le document. Je voudrais ajout de la possibilité de format "texte", par exemple
<bold>bolded text</bold> and <italic>italic</italic>
Devrait donner
<fo:block><fo:inline font-weight="bold">bolded text</fo:inline> and <fo:inline font-style="italic">italic</fo:inline>
Maintenant, j'ai assez simple document xslt, comme ceci:
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
<xsl:param name="versionParam" select="'1.0'"/>
<xsl:template match="doc">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm">
<fo:region-body margin="2cm"/>
<fo:region-before margin="0.2cm" extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:static-content flow-name="xsl-region-before" margin-right="1cm">
<fo:block text-align="start" margin-top="0.2cm">
<fo:block text-align="end" margin-top="0.2cm">
Page <fo:page-number/> of <fo:page-number-citation ref-id="terminator"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:apply-templates select="par/point"/>
<fo:block id="terminator"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="point">
<fo:block font-size="16pt" space-after="5mm">
<xsl:value-of select="tresc"/>
</fo:block>
</xsl:template>
</xsl:stylesheet>
Dois-je ajouter un autre modèle (gras, italique)? Comment suis-je censé l'appeler dans "texte" nœud?
J'ai trouvé une solution:
<xsl:template match="//bold">
<fo:inline font-weight="bold">
<xsl:value-of select="current()"></xsl:value-of>
</fo:inline>
</xsl:template>
Mais il ne fonctionne pas pour moi. Sortie de xsl-fo dosn contient pas de fo:inline.
OriginalL'auteur dce | 2011-08-12
Vous devez vous connecter pour publier un commentaire.
Oeil à cet exemple. Il montre clairement comment le hanlde inline nœuds.
[XSLT 1.0]
donné:
produit:
select="node()"
sont redondantes. À partir de w3.org/TR/xslt#section-Applying-Template-Rules: "En l'absence d'unselect
attribut, lexsl:apply-templates
processus d'instruction de tous les enfants du nœud courant, y compris les nœuds de texte."OriginalL'auteur Emiliano Poggi