xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JBry...@s-s-t.com
Subject Re: Spam:HTML tags in XML with XSL-FO
Date Thu, 07 Apr 2005 14:32:24 GMT
Bear in mind that, when you put HTML tags into XML source files, those 
tags aren't HTML tags. They are XML elements, same as everything else in 
the document. By coincidence, they happen to have the same names as some 
HTML tags. In other words, HTML tags are just like other elements until an 
HTML parser gets them.

Consequently, you can write templates to handle these source elements just 
as you would any other source elements.

For FO output, those three could be:

<xsl:template match="br">
  <fo:block/>
</xsl:template>

<xsl:template match="i">
  <fo:inline font-style="italic"><xsl:apply-templates/></fo:inline>
</xsl:template>

<xsl:template match="b">
  <fo:inline font-weight="bold"><xsl:apply-templates/></fo:inline>
</xsl:template>

Note: You should use apply-templates rather than value-of for situations 
like this because you may get another embedded element within the current 
element, as in <b><i>Some Text</i></b>

For HTML output, you can use copy-of, thus:

<xsl:templmate match="br">
  <xsl:copy-of select="."/>
</xsl:template>

<xsl:templmate match="i">
  <xsl:copy-of select="."/>
</xsl:template>

<xsl:templmate match="b">
  <xsl:copy-of select="."/>
</xsl:template>

Personally, I generally use one XML file and two XSL files (one for PDF 
and one for HTML). (In one weird case, I had eight XSL files against one 
DTD, but it's usually just two.)

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




Vojko <vojko@dhimahi.com> 
04/07/2005 07:49 AM
Please respond to
fop-users@xmlgraphics.apache.org


To
"fop-users@xmlgraphics.apache.org" <fop-users@xmlgraphics.apache.org>
cc

Subject
Spam:HTML tags in XML with XSL-FO






Hi

I have one XML for generating HTML with XSL and for generating PDF with
XSL-FO. What would be the easiest and most convenient way to have HTML
tags such as <br>, <b> or <i> inside XML and still could pars it to PDF
with XSL-FO.

The end result would have to be the same. In HTML and PDF...something in
bold, italic...or what ever I defined with HTML tag in XML.

Is this the right way to do it anyway?

Regards, V.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message