Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 1st, 2008, 06:59 PM
Registered User
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Basic Positioning

Hi, this should be a fairly easy question as I'm new to the language:

I'm using an xSLT spreadsheet to convert an XML document into xHTML. Imagine the following xml:

<root>
<briefing>
This is all text but <bottom> this </bottom> should appear at the bottom of the page.
</briefing>
</root>

Obviously I can pick out that tag and edit the text within it:

<xsl:template match="bottom">

But how could I actually move it so it was at the bottom of the page separate from everything else?

Thanks for your help :)

 
Old December 1st, 2008, 07:05 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need to structure your code to match the structure of the output, not the structure of the input. So it's not a case of "when I find <bottom/> in the input, what should I do with it?" Rather it's a case of "at the end of processing a page, find the <bottom/> elements that need to be output here".

I don't know what output vocabulary you are using (HTML doesn't have pages - is it XSL-FO?) so I can't be more precise than that. Layout of footnotes can be a tricky subject and I'm no expert.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old December 1st, 2008, 07:19 PM
Registered User
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply,

In my case the xml document is simply linked to an xSLT stylesheet:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="bottom.xls"?>

Hmmm, so I need to display those nodes at the end of my body?

<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="url" >

<xsl:template match="/" >
<html>
     <body>
         <xsl:apply-templates/>
     </body>
</html>
</xsl:template>

But if I was to call apply-templates again, I don't see how I could have it so it just displayed the <bottom> tag contents?
 
Old December 1st, 2008, 07:30 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Well, one way would be:

<xsl:template match="/" >
   <html>
      <body>
         <xsl:apply-templates/>

         <h2>Notes</h2>
         <xsl:apply-templates select="//bottom" mode="footnote"/>
      </body>
   </html>
</xsl:template>


<xsl:template match="bottom">
  [<a href="#{generate-id()}"><xsl:number level="any"/></a>]
</xsl:template>

<xsl:template match="bottom" mode="footnote">
  <p><a name="{generate-id()}">
    [<xsl:number level="any"/>]
    <xsl:value-of select="."/></a></p>
</xsl:template>

When the bottom element is processed on the first pass, it generates a link. When it is processed again on the second pass, it generates the text of the footnote, together with an anchor for the link.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old December 1st, 2008, 07:45 PM
Registered User
 
Join Date: Dec 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great, thankyou!






Similar Threads
Thread Thread Starter Forum Replies Last Post
form positioning jeremy1048 Access 2 February 12th, 2008 08:52 AM
Positioning Calculations rit01 ASP.NET 1.x and 2.0 Application Design 3 February 22nd, 2006 03:10 PM
Positioning Problem harpua CSS Cascading Style Sheets 5 May 27th, 2005 08:03 AM
fixed positioning mackknife BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 May 8th, 2005 10:37 AM
cursor positioning alihussein3 Javascript How-To 1 October 22nd, 2003 03:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.