Re: normalize-scape.mod.xsl
ben <[email protected]> Wed, 02 Jul 2003 20:50:56 +0200
| Newsgroups | gmane.text.docbook.db2latex.devel |
|---|---|
| Message-ID | <[email protected]> |
Il s'agit d'un message multivolet au format MIME.
--------------8607A634A6C5F6B60C90244D
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
James Devenish a écrit :
> However, thanks to your prompting, perhaps we can come to a compromise:
> we will still use the long, monolithic "scape" template but it will be
> generated from a mapping file (not hand-coded).
>
Hi,
If it can be of some help, in dblatex I use an engine to build the entities
translation template. The attached files (used for MathML translation):
map2func.xsl is the template to apply on mapmmlent.xml. The output is a stylesheet
containing the templates, each template name corresponding to a <mapgroup> name.
Of course the code produced is ugly, but it works fine, and it is fast enough. For
instance, applying the scape template on a test file takes 147.1 s, using the
produced template takes 96 s.
Bye,
BG
--------------8607A634A6C5F6B60C90244D
Content-Type: text/plain; charset=us-ascii;
name="map2func.xsl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="map2func.xsl"
<?xml version='1.0'?>
<xsl:stylesheet version='1.0'
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<xsl:template match="mapgroup">
<xsl:element name="xsl:template">
<xsl:variable name="n" select="@name"/>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="xsl:param">
<xsl:attribute name="name">
<xsl:text>content</xsl:text>
</xsl:attribute>
</xsl:element>
<xsl:element name="xsl:if">
<xsl:attribute name="test">
<xsl:text>string-length($content)>0</xsl:text>
</xsl:attribute>
<xsl:text> </xsl:text>
<xsl:element name="xsl:choose">
<xsl:text> </xsl:text>
<xsl:for-each select="map">
<xsl:text> </xsl:text>
<xsl:variable name="quot">
<xsl:choose>
<xsl:when test="contains(@key, "'")">
<xsl:text>"</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>'</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="xsl:when">
<xsl:attribute name="test">
<xsl:text>starts-with($content,</xsl:text>
<xsl:value-of select="$quot"/>
<xsl:value-of select="@key"/>
<xsl:value-of select="$quot"/>
<xsl:text>)</xsl:text>
</xsl:attribute>
<xsl:choose>
<xsl:when test="contains(@text, "'")">
<xsl:element name="xsl:text">
<xsl:value-of select="@text"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="xsl:value-of">
<xsl:attribute name="select">
<xsl:text>'</xsl:text>
<xsl:value-of select="@text"/>
<xsl:text>'</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
<xsl:element name="xsl:call-template">
<xsl:attribute name="name">
<xsl:value-of select="$n"/>
</xsl:attribute>
<xsl:element name="xsl:with-param">
<xsl:attribute name="name">
<xsl:text>content</xsl:text>
</xsl:attribute>
<xsl:attribute name="select">
<xsl:text>substring-after($content,</xsl:text>
<xsl:value-of select="$quot"/>
<xsl:value-of select="@key"/>
<xsl:value-of select="$quot"/>
<xsl:text>)</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:for-each>
<xsl:element name="xsl:otherwise">
<xsl:element name="xsl:value-of">
<xsl:attribute name="select">
<xsl:text>substring($content,1,1)</xsl:text>
</xsl:attribute>
</xsl:element>
<xsl:element name="xsl:call-template">
<xsl:attribute name="name">
<xsl:value-of select="$n"/>
</xsl:attribute>
<xsl:element name="xsl:with-param">
<xsl:attribute name="name">
<xsl:text>content</xsl:text>
</xsl:attribute>
<xsl:attribute name="select">
<xsl:text>substring($content,2)</xsl:text>
</xsl:attribute>
</xsl:element>
</xsl:element>
</xsl:element> <!-- xsl:otherwise -->
</xsl:element> <!-- xsl:choose -->
</xsl:element> <!-- xsl:if -->
</xsl:element>
</xsl:template>
<xsl:template match="mapping">
<xsl:element name="xsl:stylesheet">
<xsl:attribute name="version">
<xsl:text>1.0</xsl:text>
</xsl:attribute>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
--------------8607A634A6C5F6B60C90244D
Content-Type: text/plain; charset=us-ascii;
name="mapmmlent.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="mapmmlent.xml"
<?xml version='1.0'?>
<!-- generated by func2map on entities.xsl.ref -->
<!DOCTYPE mapping SYSTEM "../mapping.dtd">
<mapping>
<mapgroup name="replaceEntities">
<map key=" " text="\; "/>
<map key="ɛ" text="\varepsilon "/>
<map key="˙" text="\dot{}"/>
<map key="£" text="\pounds "/>
<map key="¥" text="\yen "/>
<map key="§" text="\S "/>
<map key="©" text="\copyright "/>
<map key="¬" text="\neg "/>
<map key="®" text="\circledR "/>
<map key="±" text="\pm "/>
<map key="µ" text="\mu "/>
<map key="¶" text="\P "/>
<map key="Å" text="\AA "/>
<map key="Æ" text="\AE "/>
<map key="×" text="\times "/>
<map key="æ" text="\ae "/>
<map key="Α" text="{\rm A}"/>
<map key="Β" text="{\rm B}"/>
<map key="Γ" text="\Gamma "/>
<map key="Δ" text="\Delta "/>
<map key="Ε" text="{\rm E}"/>
<map key="Ζ" text="{\rm Z}"/>
<map key="Η" text="{\rm H}"/>
<map key="Θ" text="\Theta "/>
<map key="Ι" text="{\rm I}"/>
<map key="Κ" text="{\rm K}"/>
<map key="Λ" text="\Lambda "/>
<map key="Μ" text="{\rm M}"/>
<map key="Ν" text="{\rm N}"/>
<map key="Ξ" text="\Xi "/>
<map key="Ο" text="{\rm O}"/>
<map key="Π" text="\Pi "/>
<map key="Ρ" text="{\rm P}"/>
<map key="Σ" text="\Sigma "/>
<map key="Τ" text="{\rm T}"/>
<map key="Υ" text="{\rm Y}"/>
<map key="Φ" text="\Phi "/>
<map key="Χ" text="{\rm X}"/>
<map key="Ψ" text="\Psi "/>
<map key="Ω" text="\Omega "/>
<map key="α" text="\alpha "/>
<map key="β" text="\beta "/>
<map key="γ" text="\gamma "/>
<map key="δ" text="\delta "/>
<map key="ε" text="\epsilon "/>
<map key="ζ" text="\zeta "/>
<map key="η" text="\eta "/>
<map key="θ" text="\theta "/>
<map key="ι" text="\iota "/>
<map key="κ" text="\kappa "/>
<map key="λ" text="\lambda "/>
<map key="μ" text="\mu "/>
<map key="ν" text="\nu "/>
<map key="ξ" text="\xi "/>
<map key="ο" text="o"/>
<map key="π" text="\pi "/>
<map key="ρ" text="\rho "/>
<map key="ς" text="\varsigma "/>
<map key="σ" text="\sigma "/>
<map key="τ" text="\tau "/>
<map key="υ" text="\upsilon "/>
<map key="φ" text="\phi "/>
<map key="χ" text="\chi "/>
<map key="ψ" text="\psi "/>
<map key="ω" text="\omega "/>
<map key="ϑ" text="\vartheta "/>
<map key="ϒ" text="\Upsilon "/>
<map key="ϕ" text="\varphi "/>
<map key="ϖ" text="\varpi "/>
<map key="ϰ" text="\varkappa "/>
<map key="ϱ" text="\varrho "/>
<map key=" " text="\hspace{0.6em}"/>
<map key=" " text="\hspace{1em}"/>
<map key=" " text="\hspace{0.33em}"/>
<map key=" " text="\hspace{0.25em}"/>
<map key=" " text="\hspace{0.17em}"/>
<map key="​" text=""/>
<map key="‖" text="\| "/>
<map key="…" text="\dots "/>
<map key="′" text="\prime "/>
<map key="⁡" text=""/>
<map key="⁢" text=""/>
<map key="⁣" text=""/>
<map key="ℋ" text="\mathscr{H}"/>
<map key="ℏ︀" text="\hbar "/>
<map key="ℏ" text="\hslash "/>
<map key="ℑ" text="\Im "/>
<map key="ℓ" text="\ell "/>
<map key="ℕ" text="\mathbb{N}"/>
<map key="℘" text="\wp "/>
<map key="ℙ" text="\mathbb{P}"/>
<map key="ℚ" text="\mathbb{Q}"/>
<map key="ℜ" text="\Re "/>
<map key="ℤ" text="\mathbb{Z}"/>
<map key="Ω" text="\Omega "/>
<map key="℧" text="\mho "/>
<map key="ℵ" text="\aleph "/>
<map key="ℶ" text="\beth "/>
<map key="ℷ" text="\gimel "/>
<map key="ℸ" text="\daleth "/>
<map key="ⅅ" text="D"/>
<map key="ⅆ" text="d"/>
<map key="ⅇ" text="e"/>
<map key="ⅈ" text="i"/>
<map key="ⅉ" text="j"/>
<map key="←" text="\leftarrow "/>
<map key="↑" text="\uparrow "/>
<map key="→" text="\to "/>
<map key="↓" text="\downarrow "/>
<map key="↔" text="\leftrightarrow "/>
<map key="↕" text="\updownarrow "/>
<map key="↖" text="\nwarrow "/>
<map key="↗" text="\nearrow "/>
<map key="↘" text="\searrow "/>
<map key="↙" text="\swarrow "/>
<map key="↚" text="\nleftarrow "/>
<map key="↛" text="\nrightarrow "/>
<map key="↝" text="\rightsquigarrow "/>
<map key="↞" text="\twoheadleftarrow "/>
<map key="↠" text="\twoheadrightarrow "/>
<map key="↢" text="\leftarrowtail "/>
<map key="↣" text="\rightarrowtail "/>
<map key="↦" text="\mapsto "/>
<map key="↩" text="\hookleftarrow "/>
<map key="↪" text="\hookrightarrow "/>
<map key="↫" text="\looparrowleft "/>
<map key="↬" text="\looparrowright "/>
<map key="↭" text="\leftrightsquigarrow "/>
<map key="↮" text="\nleftrightarrow "/>
<map key="↰" text="\Lsh "/>
<map key="↱" text="\Rsh "/>
<map key="↶" text="\curvearrowleft "/>
<map key="↷" text="\curvearrowright "/>
<map key="↺" text="\circlearrowleft "/>
<map key="↻" text="\circlearrowright "/>
<map key="↼" text="\leftharpoonup "/>
<map key="↽" text="\leftharpoondown "/>
<map key="↾" text="\upharpoonright "/>
<map key="↿" text="\upharpoonleft "/>
<map key="⇀" text="\rightharpoonup "/>
<map key="⇁" text="\rightharpoondown "/>
<map key="⇂" text="\downharpoonright "/>
<map key="⇃" text="\downharpoonleft "/>
<map key="⇄" text="\rightleftarrows "/>
<map key="⇆" text="\leftrightarrows "/>
<map key="⇇" text="\leftleftarrows "/>
<map key="⇈" text="\upuparrows "/>
<map key="⇉" text="\rightrightarrows "/>
<map key="⇊" text="\downdownarrows "/>
<map key="⇋" text="\leftrightharpoons "/>
<map key="⇌" text="\rightleftharpoons "/>
<map key="⇍" text="\nLeftarrow "/>
<map key="⇎" text="\nLeftrightarrow "/>
<map key="⇏" text="\nRightarrow "/>
<map key="⇐" text="\Leftarrow "/>
<map key="⇑" text="\Uparrow "/>
<map key="⇒" text="\Rightarrow "/>
<map key="⇓" text="\Downarrow "/>
<map key="⇔" text="\Leftrightarrow "/>
<map key="⇔" text="\iff "/>
<map key="⇕" text="\Updownarrow "/>
<map key="⇚" text="\Lleftarrow "/>
<map key="⇛" text="\Rrightarrow "/>
<map key="∀" text="\forall "/>
<map key="∁" text="\complement "/>
<map key="∂" text="\partial "/>
<map key="∃" text="\exists "/>
<map key="∄" text="\nexists "/>
<map key="∅︀" text="\emptyset "/>
<map key="∅" text="\varnothing "/>
<map key="∆" text=" "/>
<map key="∇" text="\nabla "/>
<map key="∈" text="\in "/>
<map key="∉" text="\notin "/>
<map key="∋" text="\ni "/>
<map key="∌" text="\not\ni "/>
<map key="∏" text="\prod "/>
<map key="∐" text="\coprod "/>
<map key="∑" text="\sum "/>
<map key="−" text="-"/>
<map key="∓" text="\mp "/>
<map key="∔" text="\dotplus "/>
<map key="∕" text=" "/>
<map key="∖" text="\setminus "/>
<map key="∗" text="\ast "/>
<map key="∘" text="\circ "/>
<map key="∙" text="\bullet "/>
<map key="√" text="\surd "/>
<map key="∝" text="\propto "/>
<map key="∞" text="\infty "/>
<map key="∟" text=" "/>
<map key="∠" text="\angle "/>
<map key="∡" text="\measuredangle "/>
<map key="∢" text="\sphericalangle "/>
<map key="∣" text="\mid "/>
<map key="∤︀" text="\nshortmid "/>
<map key="∤" text="\nmid "/>
<map key="∥" text="\parallel "/>
<map key="∦︀" text="\nshortparallel "/>
<map key="∦" text="\nparallel "/>
<map key="∧" text="\wedge "/>
<map key="∨" text="\vee "/>
<map key="∩" text="\cap "/>
<map key="∪" text="\cup "/>
<map key="∫" text="\int "/>
<map key="∬" text="\iint "/>
<map key="∭" text="\iiint "/>
<map key="∮" text="\oint "/>
<map key="∯" text=" "/>
<map key="∰" text=" "/>
<map key="∱" text=" "/>
<map key="∲" text=" "/>
<map key="∳" text=" "/>
<map key="∴" text="\therefore "/>
<map key="∵" text="\because "/>
<map key="∶" text=":"/>
<map key="∷" text="\colon\colon "/>
<map key="∸" text="\dot{-}"/>
<map key="∹" text=" "/>
<map key="∺" text=" "/>
<map key="∻" text=" "/>
<map key="∼" text="\sim "/>
<map key="∽" text="\backsim "/>
<map key="∾" text=" "/>
<map key="∿" text=" "/>
<map key="≀" text="\wr "/>
<map key="≁" text="\nsim "/>
<map key="≂" text="\eqsim "/>
<map key="≃" text="\simeq "/>
<map key="≄" text="\not\simeq "/>
<map key="≅" text="\cong "/>
<map key="≆" text=" "/>
<map key="≇" text="\ncong "/>
<map key="≈" text="\approx "/>
<map key="≉̸" text=" "/>
<map key="≉" text="\not\approx "/>
<map key="≊" text="\approxeq "/>
<map key="≋" text=" "/>
<map key="≌" text=" "/>
<map key="≍" text="\asymp "/>
<map key="≎" text="\Bumpeq "/>
<map key="≏" text="\bumpeq "/>
<map key="≐" text="\doteq "/>
<map key="≑" text="\doteqdot "/>
<map key="≒" text="\fallingdotseq "/>
<map key="≓" text="\risingdotseq "/>
<map key="≔" text=" "/>
<map key="≕" text=" "/>
<map key="≖" text="\eqcirc "/>
<map key="≗" text="\circeq "/>
<map key="≘" text="\stackrel{\frown}{=}"/>
<map key="≙" text="\stackrel{\wedge}{=}"/>
<map key="≚" text="\stackrel{\vee}{=}"/>
<map key="≛" text="\stackrel{\star}{=}"/>
<map key="≜" text="\triangleq "/>
<map key="≝" text="\stackrel{\scriptscriptstyle\mathrm{def}}{=}"/>
<map key="≞" text="\stackrel{\scriptscriptstyle\mathrm{m}}{=}"/>
<map key="≟" text="\stackrel{?}{=}"/>
<map key="≠︀" text=" "/>
<map key="≠" text="\ne "/>
<map key="≡⃥" text=" "/>
<map key="≡" text="\equiv "/>
<map key="≢" text="\not\equiv "/>
<map key="≣" text=" "/>
<map key="≤" text="\le "/>
<map key="≥" text="\ge "/>
<map key="≦" text="\leqq "/>
<map key="≧" text="\geqq "/>
<map key="≨" text="\lneqq "/>
<map key="≩" text="\gneqq "/>
<map key="≪̸︀" text=" "/>
<map key="≪̸" text=" "/>
<map key="≪" text="\ll "/>
<map key="≫̸︀" text=" "/>
<map key="≫̸" text=" "/>
<map key="≫" text="\gg "/>
<map key="≬" text="\between "/>
<map key="≭" text="\not\asymp "/>
<map key="≮" text="\nless "/>
<map key="≯" text="\ngtr "/>
<map key="≰⃥" text="\nleq "/>
<map key="≰" text="\nleqq "/>
<map key="≱⃥" text="\ngeq "/>
<map key="≱" text="\ngeqq "/>
<map key="≲" text="\lesssim "/>
<map key="≳" text="\gtrsim "/>
<map key="≴" text="\not\lesssim "/>
<map key="≵" text="\not\gtrsim "/>
<map key="≶" text="\lessgtr "/>
<map key="≷" text="\gtrless "/>
<map key="≸" text="\not\lessgtr "/>
<map key="≹" text="\not\gtrless "/>
<map key="≺" text="\prec "/>
<map key="≻" text="\succ "/>
<map key="≼" text="\preccurlyeq "/>
<map key="≽" text="\succcurlyeq "/>
<map key="≾" text="\precsim "/>
<map key="≿" text="\succsim "/>
<map key="⊀" text="\nprec "/>
<map key="⊁" text="\nsucc "/>
<map key="⊂" text="\subset "/>
<map key="⊃" text="\supset "/>
<map key="⊄" text="\not\subset "/>
<map key="⊅" text="\not\supset "/>
<map key="⊆" text="\subseteq "/>
<map key="⊇" text="\supseteq "/>
<map key="⊎" text="\uplus "/>
<map key="⊓" text="\sqcap "/>
<map key="⊔" text="\bigsqcup "/>
<map key="⊕" text="\oplus "/>
<map key="⊖" text="\ominus "/>
<map key="⊗" text="\otimes "/>
<map key="⊘" text="\oslash "/>
<map key="⊙" text="\odot "/>
<map key="⊟" text="\boxminus "/>
<map key="⊤" text="\top "/>
<map key="⊥" text="\perp "/>
<map key="⊦" text="\vdash "/>
<map key="⊧" text="\vDash "/>
<map key="⊨" text="\models "/>
<map key="⊪" text="\Vvdash "/>
<map key="⋀" text="\bigwedge "/>
<map key="⋁" text="\bigvee "/>
<map key="⋂" text="\bigcap "/>
<map key="⋃" text="\bigcup "/>
<map key="⋄" text="\diamond "/>
<map key="⋅" text="\cdot "/>
<map key="⋆" text="\star "/>
<map key="⋇" text="\divideontimes "/>
<map key="⋈" text="\bowtie "/>
<map key="⋍" text="\backsimeq "/>
<map key="⋯" text="\cdots "/>
<map key="⋰" text=" "/>
<map key="⋱" text="\ddots "/>
<map key="⌈" text="\lceil "/>
<map key="⌉" text="\rceil "/>
<map key="⌊" text="\lfloor "/>
<map key="⌋" text="\rfloor "/>
<map key="〈" text="\langle "/>
<map key="〉" text="\rangle "/>
<map key="□" text="\square "/>
<map key="▪" text="\blacksquare "/>
<map key="'" text="\text{'}"/>
<map key="{" text="\{"/>
<map key="}" text="\}"/>
<map key="$" text="\$"/>
<map key="#" text="\#"/>
<map key="&" text="\&"/>
<map key="%" text="\%"/>
<map key="_" text="\_"/>
<map key="\" text="\backslash "/>
</mapgroup>
<mapgroup name="replaceMtextEntities">
<map key="   " text="\hspace{0.28em}"/>
<map key=" " text="\hspace{0.6em}"/>
<map key=" " text="\hspace{1em}"/>
<map key=" " text="\hspace{0.33em}"/>
<map key=" " text="\hspace{0.25em}"/>
<map key=" " text="\hspace{0.17em}"/>
<map key=" " text="\hspace{0.05em}"/>
<map key="​" text=""/>
<map key=" " text="\hspace{0.22em}"/>
<map key="$" text="\$"/>
<map key="#" text="\#"/>
<map key="&" text="\&"/>
<map key="%" text="\%"/>
<map key="_" text="\_"/>
<map key="\" text=""/>
</mapgroup>
</mapping>
--------------8607A634A6C5F6B60C90244D--
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01