xsl-list
[Top] [All Lists]

RE: displaying xslt using xsl:fo

2002-11-14 09:27:11

bryan:
<fo:inline>&lt;</fo:inline><xsl:value-of select="name()"/>

really..? I started down this route, using code like:

  <fo:block>
    <xsl:text>&lt;</xsl:text>
    <xsl:value-of select="name()"/>
    <xsl:text>&gt;</xsl:text>
    <xsl:apply-templates/>
    <xsl:text>&lt;/</xsl:text>
    <xsl:value-of select="name()"/>
    <xsl:text>&gt;</xsl:text>
  </fo:block>

and it felt like I was suffering the fate of many newbies and heading in
the wrong direction!

To avoid writing rules for each of the xslt elements, Ive just tried
using this:

  <fo:block>
    <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
    <xsl:copy-of select="."/>
    <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  </fo:block>

..which gets the templates through to the output, but the presentational
whitespace seems to be ignored (the code is just one lump)

I tried using white-space-treatment="preserve", but fop tells me it
doesn't implement this yet.  Are any of the other fo processors capable
of this?    

thanks for help
andrew




-----Original Message-----
From: bryan [mailto:bry(_at_)itnisk(_dot_)com]
Sent: 14 November 2002 15:36
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] displaying xslt using xsl:fo



Has anyone written a xsl:fo stylesheet to display xslt (or 
any kind of
markup)?

Its appears that fop is treating all the xslt and html mark up as
instructions, almost as if it isnt namespace aware...  I've only
started
on xsl:fo today (with the help Dave P's online book, cheers dave!) so
any gentle looseners are appreciated.

Well you'd need to have a generic markup handler in the same way you
would need it if you wanted to display markup in your html.

At that point I guess it just becomes a question as to how do 
I want to
display markup when printing to a pdf, i.e a logic of presentation
question. Are there any parts of xslt markup that should be presented
differently than other parts. Probably you would want to have two
different types of block containers for 
xsl:template[(_at_)match] and xsl:template[(_at_)name]
then everything below that in the xsl namespace gets 
individual blocks,
everything not in the xsl namespace goes into one block with escaped
markup.

<xsl:template match="foo">
<bar/>
</xsl:template>

gets analyzed, without presentation properties of attributes, in this
way

<xsl:template match="xsl:template[(_at_)match]">
<fo:block-container><fo:block><xsl:call-template name="tagmatcher1"/>
</fo:block>
<xsl:apply-templates mode="genericmarkup"/>
<fo:block><xsl:call-template name="tagender1"/> </fo:block>
</fo:block-container>
</xsl:template>

<xsl:template name="tagmatcher1">
<fo:inline>&lt;</fo:inline><xsl:value-of select="name()"/> 
<xsl:for-each
select="@*"><fo:inline><xsl:value-of
select="name()"/></fo:inline>="<xsl:value-of
select="."/>"</xsl:for-each><fo:inline>&gt;</fo:inline>
</xsl:template>

<xsl:template name="tagender1">
<fo:inline>&lt;/</fo:inline><xsl:value-of
select="name()"/><fo:inline>&gt;</fo:inline>

</xsl:template>

<xsl:template match="*" mode="genericmarkup">
<fo:block><xsl:call-template name="tagmatcher1"/> </fo:block>
<xsl:apply-templates mode="genericmarkup"/>
<fo:block><xsl:call-template name="tagender1"/> </fo:block>
</xsl:template>

which would give you something like this(supposing I haven't made any
semantic mistakes above nor any keyboard entry errors below)

<fo:block-container>
<fo:block><fo:inline>&lt;xsl:template</fo:inline>
<fo:inline>match</fo:inline>="foo"<fo:inline>&gt;</fo:inline><
/fo:block>

<fo:block><fo:inline>&lt;</fo:inline>
bar<fo:inline>&gt;</fo:inline></fo:block>
<fo:block><fo:inline>&lt;/</fo:inline>bar<fo:inline>&gt;</fo:i
nline></fo
:block>

<fo:block><fo:inline>&lt;/</fo:inline>
xsl:template<fo:inline>&gt;</fo:inline></fo:block>
</fo:block-container>

this is similar to what I do with anything contained within a <code
type="markup"></code> node in my markup.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>