|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Breaking up XML(XHTML) into pages
Hi David, Sorry that I didn?t explaining clearly my problem. Actually, I have produce a Web page using an XHTML file. IT looks like that: <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="one.xsl" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; accept-charset=utf-8"/> <title>Title</title> <meta content="some keywords here" name="keywords"/> <meta content="a description of the page here" name="description"/> </head> <body> <div> <img src="/C:/My Documents/leo/ee3.gif" alt="Labs" title="The Photo" height="287"/> </div> <h1>Header same as Title</h1> <h2>Header</h2> <h3>Header</h3> <p>Text</p> <p>Text</p> <div class="section"> <h2>Welcome</h2> <p>Text</p> <p>Text</p> </div> <div class="section"> <h2> <a href="http://www.hotmail.com ">Hotmail</a> </h2> </div> <div class="section">
<h2>People</h2>
<p>Text<p>
<p>Text</p>
</div>
<div class="section">
???????..
???????.
</div>
</body>
</html>I use three stylesheets. One to produce a standard header, one for a standard footer and one main xsl to call the other two and bind the hall output. With the header, I apply a photo as well as a table of contents.. This table contains the h2 headers from the XHTML. Some of them as you can see are external links. I succeed to produce this table with internal and external links using the generate-id() function. Everything seems to work fine but the problem is that I have to break up this xhtml in pages. I would like to type at the url: http://mypage.xml?page1 and get the first h2 section (Welcome) in a web page with my standard header and footer. That?s why I am looking at the parameter solution: <input name="page_number" value="{$page_number}"/> The idea is that the end user can be navigated with Prev. and Next to all the sections of my XHTML. <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"> <xsl:import href="header.xsl"/> <xsl:import href="footer.xsl"/> In order to apply all the numbers of the sections to the parameter I thought to do something like that: <xsl:param name="page_number" select="following-sibling::div[@class='section'][position()=1]"/> So I can type to the url different page its time: http://mypage.xml?page1 http://mypage.xml?page2 <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="xhtml:head"> <link rel="alternate stylesheet" title="simple" href="simpletext.css" type="text/css"/> <xsl:copy-of select="."/> </xsl:template> <xsl:template match="xhtml:body"> <body> <xsl:call-template name="header"/> <xsl:call-template name="footer"/> </body> <!-- manage h2 elements --> <xsl:template match="//xhtml:div[@class='section']/xhtml:h2"> <xsl:choose> <xsl:when test="./xhtml:a"> </xsl:when> <xsl:otherwise> <h2 class="section" id="{generate-id()}"> <a name="{generate-id()}"> <xsl:value-of select="*"> </xsl:value-of> <xsl:apply-templates/> </a> </h2> </xsl:otherwise> </xsl:choose> </xsl:template> Here I try to apply the parameter for every div that contains h2 <!--****************************--> <xsl:template match="//xhtml:div[@class='section']"> <xsl:if test="./div[@class='section']"> <input name="page_number" value="{$page_number}"/> <xsl:value-of select="*"> </xsl:value-of> <xsl:apply-templates/> </xsl:if> </xsl:template> <!--****************************--> <!--manage h1 in the body,not sow them, but use them for the header--> <xsl:template match="//xhtml:h1"> <xsl:if test="./xhtml:h1"> </xsl:if> </xsl:template> <!--manage <img > in the body,not sow them, but let the stylesheet use them if available--> <xsl:template match="//xhtml:img"> <xsl:if test="./xhtml:img"> </xsl:if> </xsl:template> <!-- default: just copy input to output --> <xsl:template match="*|text()|*/comment()|processing-instruction()"> <xsl:copy> <xsl:for-each select="@*"> <xsl:copy/> </xsl:for-each> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> Until now, the only thing I succeed is to produce a page with my standard header and footer, h1, h2, h3 and the first paragraphs that are not inside div: <h1>Header same as Title</h1> <h2>Header</h2> <h3>Header</h3> <p>Text</p> <p>Text</p> I use XMLSPY 5 under trial and the debugger seems to see the sections : <xsl:if test="./div[@class='section']">
<input name="page_number" value="{$page_number}"/>
<xsl:value-of select="*">
</xsl:value-of>
<xsl:apply-templates/>
</xsl:if>but doesn?t display the one I want. I search the xslt-list and a lot of sites in the net for an example but when someone want to do something like that, uses FO-Blocks and I am not familiar with that. Sorry if I take a lot of your time but even a reference for a related example would be really helpful. Regards Leo _________________________________________________________________ The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








