[xsl] XSL-FO template for including another document

Subject: [xsl] XSL-FO template for including another document
From: Arian Hojat <arianhojat2000@xxxxxxxxx>
Date: Mon, 13 Jun 2005 06:46:13 -0700 (PDT)
(I am resending this email to list cause it seems like
my one from last 
week didnt get through)

Hello everyone,

I am building an XHTML to XSL-FO (for pdf output)
stylesheet and i have 
a problem regarding lists in XSL-FO and making an
appropriate 
stylesheet. In XSL-FO. You can have a list within a
list but unlike html it 
seems, it does not automatically indent the list just
by having it as a 
subitem of another list (you have to specify an
indentation with a 
count(ancestor::ol | ancestor|ul) * value. Now in my
XHTML-like language i have 
an element called <include href="other.xml">... this
include element can include 
another xhtml mini-doc to bring into the pdf output
(to segment documents 
in pieces making it easier on author to edit). and
there is a template 
rule to look at the included document and apply
templates to it. But if a list 
element has an include within it, which has another
list in that file, 
when it applies templates and gets to the sublist, it
has 0 ancestors 
since the template is now looking at a new doc. is
there anyway to do a 
<xsl:apply-templates
select="document(@href)/Document/*"/> but instead 
of
'going' to the new document and applying templates to
it, to 'pull it 
inside' the xml that called it, so it can see it has
ancestors? heh 
this sounds confusing now that i reread it.The best
solution is maybe 
coming up with a system to send a parameter of a count
of all the ul/ol, 
but wasnt sure if this would be as easy too.

calling xml document

###############

<Document fileName="Quality_Control_Overview1">
<ul name="1stDoc_1stList">
<li>a</li>
<li>b</li>

    <ul name="1stDoc_2ndList">
    <li>c</li>
    <li>d</li>

        <ol name="1stDoc_3rdList">
        <li>e</li>
        <li>f</li>
        <include href="2.xml" />
        </ol>

    </ul>

</ul>
</Document>

###############

called xml doc (2.xml)

###############
<Document fileName="Quality_Control_Overview2">
<ul name="2ndDoc_1stList"> <! -- will not see
1stDoc_3rdList etc as its 
parents-->
    <ul name="2ndDoc_2ndList">
        <ul name="2ndDoc_3rdList">
        <li>a</li>
        <li>b</li>
        </ul>
    </ul>
</ul>
</Document>
###############

important parts of xsl... (most borrowed from a
html2pdf doc)... in 
that ordered list the important part that causes
trouble is 
"(count(ancestor::ol)+count(ancestor::ul)) * 1.25"

since it wont see if it has parent ol or ul's from
another doc that 
includes it.

###############

<xsl:template match="include">
<xsl:apply-templates
select="document(@href)/Document/*"/>
</xsl:template>

....

....

....

<xsl:template match="ol">
<fo:list-block
provisional-distance-between-starts="1cm"
provisional-label-separation="0.5cm"
space-before="10pt">


<xsl:attribute name="space-after">
<xsl:choose>
<xsl:when test="ancestor::ul or ancestor::ol">
<xsl:text>0pt</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>12pt</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>

<xsl:attribute name="start-indent">
<xsl:variable name="ancestors">
<xsl:choose>
<xsl:when test="count(ancestor::ol) or
count(ancestor::ul)">
<xsl:value-of select="1 + (count(ancestor::ol) +
count(ancestor::ul)) * 1.25"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($ancestors, 'cm')"/>
</xsl:attribute>

<xsl:apply-templates select="*"/>

</fo:list-block>
</xsl:template>



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread