xsl-list
[Top] [All Lists]

Re: Creating Drop Caps with XSL

2004-10-12 13:37:21
Actually, your footnote element is seen by your processor as and
element... all properly formed markup is as long as it is not contained
in a CDATA tag.  

For a deep copy of an element (itself and all of it descendants) try
copy-of instead of copy.

Best of luck!

<M:D/>


On Tue, 2004-10-12 at 12:18, David Laurie wrote:
Hello XSL list,

I have been gleaning bits of coding help from the list archive for quite a 
while now (thanks!) but have run into something I cannot find a solution for 
so I finally needed to post. I am using xml and xslt to build a dynamic 
website that displays text and maps from an atlas. Our designer wants to be 
able to set off the first paragraph and first letter of each text block 
displayed.

So I want to transform something like:

<content>
    <header>Some heading</header>
    <paragraph> Some text  here. Some text  here<footnote number="1"/>. Some 
text  here. </paragraph>
    <paragraph> Some text  here. </paragraph>
    <paragraph> Some text  here.</paragraph>
</content>

into:

<content>
    <header>Some heading</header>
    <firstparagraph> <dropcap>S</dropcap>ome text  here. Some text  
here<footnote number="1"/>. Some text  here. </firstparagraph>
    <paragraph> Some text  here. </paragraph>
    <paragraph> Some text  here.</paragraph>
</content>

Following tips from list archive, I have managed to get almost proper output 
with the problem being the exclusion of the footnote tags from the newly 
created <firstparagraph> element. It is clear that this occurs because my 
xslt 
converts <paragraph> content to a string, thus omitting the <footnote> tags.

The xsl I use:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>


<xsl:template match="div/paragraph[1]">
        <xsl:variable name="dropcap" select="substring(.,1,1)"/>
        <xsl:element name="firstparagraph">
      <xsl:element name="dropcap">
            <xsl:value-of select="$dropcap"/>
        </xsl:element>
        <xsl:apply-templates select="@*|node()"/>
      </xsl:element>
</xsl:template>
<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>

I am using the cocoon xslt tansformer built-in processor (a cagey way of 
saying I don't know the name of it ;).)

The only solution I can see is to perform an intermediate transformation that 
captures all of the contents of paragraph[1] as a string (including the 
footnote tags), perform the transformation above, and then transform the 
appropriate firstparagraph contents back into tags using a string search 
operation.

I couldn't find a means of accomplishing this so I am assuming it is not the 
correct solution.

Can anyone suggest one?

Thanks for your time,

Dave

David Laurie
MA Humanities Computing


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



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