Hi,
I have the following situation:
I translate an XML datasource to PDF using an XSL stylesheet and FOP 0.95 .
I can not pause the process, e.g. for running scripts, nor can I change
the output in the XML file, so everything has to be done in the XSL
stylesheet.
In my XML file, there are elements like
<text1>blablabla&lt;br /&gt;</text1>, which contain masked HTML tags
that control
the formatting (bold, lists...).
I know how to treat unmasked HTML tags, but not how to translate
masked HTML tags into a formatting.
My idea was to write a recursive "find-and-replace"-like template, all I can
do so far
is delete thos HTML tags.
Does anyone have a template for such a job (only tags like , <ul>, <ol> and
<li> are needed)?
best regards,
Maxmus
<xsl:param name="input" />
<xsl:choose>
<xsl:when test="contains($input, '<') and
contains($input, '>')">
<xsl:choose>
<xsl:when
test="string-length(substring-before($input, '<')) <
string-length(substring-before($input, '>'))"> <!-- < before > -->
<xsl:value-of
select="substring-before($input, '<')" />
<xsl:choose>
<xsl:when
test="string-length(substring-after(substring-before($input,
'>'), '<')) < 10"><!-- less than 10 characters between the
brackets: assume it's HTML -->
X <!-- replace with an
X to see something was done -->
<xsl:call-template
name="rep_HTML">
<xsl:with-param
name="input" select="substring-after($input,
'>')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><!-- not HTML:
print the tag, but in brackets to know
that it was replaced properly -->
<xsl:value-of
select="'(<)'"/>
<xsl:call-template
name="rep_HTML">
<xsl:with-param
name="input" select="substring-after($input,
'<')" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when
test="string-length(substring-before($input, '<')) >
string-length(substring-before($input, '>'))"><!-- > before < -->
<xsl:value-of
select="substring-before($input, '>')" />
<xsl:value-of select="'(>)'"/>
<xsl:call-template name="rep_HTML">
<xsl:with-param name="input"
select="substring-after($input, '>')"
/>
</xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$input" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
--
View this message in context:
http://old.nabble.com/template-which-translates-masked-HTML--tp28107135p28107135.html
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]