Welcome to MobyThreads.com!
FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

XSLT expert? How to apply filters :/ I'm stuck!

 
   Web Hosting and Web Master Forums (Home) -> Webmaster RSS
Related Topics:
CSS for expert ; how to apply at a box the HTML's height - To apply at a box the HTML's height How I can to apply the yellow box's height how the blue box's height; that height with Mozilla, or the Netscape to the HTML 's height (rose), with 5 IE or IE 6 it to the BODY's height ..

XSLT genius required - Morning all... Okay I've been with XSLT all weekend and I'm getting nobody here knows how to use it (the only guy is off on holiday, and his handover consisted of letting me to look it up on google :/). I'm totally stuck. ..

morning all... welcome to XSLT hell... - .... :/ -- x (miranda) # lead designer @ # # remove NO SPAM to email, or use form on website #

Expert System/Inference Engine for the Web - I have written a Perl module I wish to post on CPAN. It has a number of areas one of which eases the creation of complex web sites. It is fairly robust now after two years of being used in a couple of projects. Of course the..

How to apply for an eCommerce Merchant Account - So, what do you need to sign up for an eCommerce merchant account? It's not just like signing on the dotted line. This is what you'll need to get that account up and running: Option 1) The ownership will have to have strong personal credit. Credit ..
Author Message
nothespacegirl

External


Since: Aug 11, 2004
Posts: 607



(Msg. 1) Posted: Fri Dec 03, 2004 6:35 am
Post subject: XSLT expert? How to apply filters :/ I'm stuck!
Archived from groups: alt>www>webmaster (more info?)

I'm stuck. I've got a series of sites that are using different
structures. One has its content in a div called "main", the other in a
div called "contentBoxInner". These are converted into PDF by the way of
a chunk of XSLT. I need some way of doing an "if", so basically if the
"main" div exists, use that as the page flow for the PDF, but if it
doesn't exist use the "contentBoxInner" div instead. I can get one or
the other working in isolation... but how about both???

main:

<fo:page-sequence master-reference="a4">
<xsl:apply-templates mode="header" select="//x:div[@id='header']"/>
<xsl:apply-templates mode="footer" select="//x:div[@id='footer']"/>
<xsl:apply-templates select="//x:div[@id='main']"/>
</fo:page-sequence>

contentBoxInner:

<fo:page-sequence master-reference="a4">
<xsl:apply-templates mode="header" select="//x:div[@id='header']"/>
<xsl:apply-templates mode="footer" select="//x:div[@id='footer']"/>
<xsl:apply-templates select="//x:div[@id='contentBoxInner']"/>
</fo:page-sequence>

full XSLT;

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet exclude-result-prefixes="x" version="1.1"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:x="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" omit-xml-declaration="no"
version="1.0"/>
<xsl:param name="baseHref">http://localhost</xsl:param>
<xsl:template match="x:html">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master margin-bottom="1cm"
margin-left="1cm" margin-right="1cm"
margin-top="1cm" master-name="a4"
page-height="29.7cm" page-width="21cm">
<fo:region-before extent="2.5cm" precedence="true"/>
<fo:region-after extent="0.5cm" precedence="true"/>
<fo:region-body margin-bottom="0.6cm"
margin-top="2.6cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="a4">
<xsl:apply-templates mode="header"
select="//x:div[@id='title']"/>
<xsl:apply-templates mode="footer"
select="//x:div[@id='copyright']"/>
<xsl:apply-templates
select="//x:div[@id='contentBoxInner']"/>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="x:div[@id='title']" mode="header">
<fo:static-content flow-name="xsl-region-before">
<fo:table border="#000000 0.03cm solid" padding="0.05cm"
table-layout="fixed">
<fo:table-column column-width="4cm"/>
<fo:table-column column-width="15cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell display-align="center"
text-align="center">
<fo:block>
<fo:external-graphic
content-height="1.986in"
content-width="3.694in"
height="2cm" scaling="uniform"
text-align="center" width="3.72cm">
<xsl:attribute
name="src"><xsl:value-of select="concat($baseHref,
'/gsk/images/logo.vopen.gif')"/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="center">
<xsl:apply-templates mode="header"
select=".//x:h1"/>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:static-content>
</xsl:template>
<xsl:template match="x:h1" mode="header">
<fo:block background-color="#ffffff" color="#000000"
font-family="Arial, Helvetica, sans-serif" font-size="24pt"
font-weight="bold" margin-left="0.5cm" text-align="center">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="x:h6" mode="header">
<fo:block background-color="#ffffff" color="#000000"
font-family="Arial, Helvetica, sans-serif" font-size="8pt"
font-weight="bold" text-align="center">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="x:em">
<fo:inline color="#000000">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
<!--<xsl:template match="x:div[@id='copyright']" mode="footer">
<fo:static-content flow-name="xsl-region-after">
<fo:block background-color="white" color="#666"
font-family="Arial, Helvetica, sans-serif"
font-size="8pt" text-align="center">
<xsl:apply-templates/>
</fo:block>
</fo:static-content>
</xsl:template>-->
<xsl:template match="x:div[@id='contentBoxInner']">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates/>
</fo:block>
<fo:block>
  <xsl:apply-templates select="//x:div[@id='queryStatus']"/>
</fo:block>
</fo:flow>
</xsl:template>
<xsl:template match="x:table[@class='data']">
  <xsl:variable name="numRows" select="count(.//x:tbody/x:tr)"/>
<xsl:variable name="numCols"
select="count(.//x:tbody/x:tr[1]/x:td)"/>
<xsl:variable name="ignoreCols"
select="count(.//x:tbody/x:tr[1]/x:td[@class='pdfignore'])"/>
<xsl:variable name="doubleWidthCols"
select="count(.//x:tbody/x:tr[1]/x:td[@class='doubleWidth'])"/>
<xsl:choose>
  <xsl:when test="$numRows=1 and $numCols=1">
   <fo:block text-align="center"><xsl:value-of
select=".//x:tbody/x:tr[1]/x:td"/></fo:block>
  </xsl:when>
  <xsl:otherwise>
   <fo:table display-align="center" font-family="Courier New,
Courier, mono"
    space-after="0.5cm" table-layout="fixed"
text-align="center">
   <!-- <xsl:if
test="count(following:Mad:table[@class='data']) > 0">
    <xsl:attribute name="break-after">page</xsl:attribute>
   </xsl:if> -->
   <xsl:variable name="colWidth" select="19.0 div ($numCols
- $ignoreCols + $doubleWidthCols)"/>
   <xsl:apply-templates mode="columns"
select=".//x:tbody/x:tr[1]/x:td">
   <xsl:with-param name="colWidth" select="$colWidth"/>
   </xsl:apply-templates>
   <xsl:apply-templates/>
   </fo:table>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="x:td[@class = 'pdfignore']" mode="columns"/>
<xsl:template match="x:td" mode="columns">
<xsl:param name="colWidth" select="1"/>
<xsl:choose>
  <xsl:when test="@class='doubleWidth'">
   <fo:table-column column-width="{$colWidth * 2}cm"/>
  </xsl:when>
  <xsl:otherwise>
   <fo:table-column column-width="{$colWidth}cm"/>
  </xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="x:table[@class='data']/x:thead">
<fo:table-header background-color="#dfe8fd" color="#000000"
font-size="8pt"
font-weight="bold" line-height="12pt">
<xsl:apply-templates/>
</fo:table-header>
</xsl:template>
<xsl:template match="x:table[@class='data']/*/x:tr">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:template>
<xsl:template match="x:table[@class='data']/x:tfoot">
<fo:table-footer background-color="#dfe8fd" color="#000000"
font-size="8pt"
font-weight="bold" line-height="12pt">
<xsl:apply-templates/>
</fo:table-footer>
</xsl:template>
<xsl:template match="x:table[@class='data']/*/*/x:th">
<fo:table-cell border="0.025cm solid #999999"
border-collapse="collapse">
<xsl:if test="@colspan">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="@colspan"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rowspan">
<xsl:attribute name="number-rows-spanned">
<xsl:value-of select="@rowspan"/>
</xsl:attribute>
</xsl:if>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="x:table[@class='data']/*/*/x:td">
<fo:table-cell border="0.025cm solid #999999"
border-collapse="collapse">
<xsl:if test="@colspan">
<xsl:attribute name="number-columns-spanned">
<xsl:value-of select="@colspan"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@rowspan">
<xsl:attribute name="number-rows-spanned">
<xsl:value-of select="@rowspan"/>
</xsl:attribute>
</xsl:if>
<xsl:choose>
<xsl:when test="@class='red'">
<xsl:attribute
name="background-color">#999</xsl:attribute>
<xsl:attribute name="color">black</xsl:attribute>
</xsl:when>
<xsl:when test="@class='green'">
<xsl:attribute
name="background-color">white</xsl:attribute>
<xsl:attribute name="color">black</xsl:attribute>
</xsl:when>
<xsl:when test="@class='amber'">
<xsl:attribute name="color">black</xsl:attribute>
<xsl:attribute
name="background-color">#ccc</xsl:attribute>
</xsl:when>
<xsl:when test="@class='empty'">
<xsl:attribute
name="background-color">#888</xsl:attribute>
<xsl:attribute name="color">white</xsl:attribute>
</xsl:when>
<xsl:when test="@class='label'">
<xsl:attribute
name="background-color">#dfe8fd</xsl:attribute>
<xsl:attribute name="color">#000000</xsl:attribute>
<xsl:attribute name="font-weight">bold</xsl:attribute>
<xsl:attribute name="text-align">right</xsl:attribute>
</xsl:when>
</xsl:choose>
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:table-cell>
</xsl:template>
<xsl:template match="x:table[@class='data']/x:tbody">
<fo:table-body background-color="#ffffff" color="#000000"
font-size="8pt"
font-weight="normal" line-height="12pt">
<xsl:apply-templates/>
</fo:table-body>
</xsl:template>
<xsl:template match="x:h2">
<fo:block color="#cc0000" font-family="serif" font-size="14pt"
keep-with-next.within-page="always" space-after="0.3cm"
text-align="center">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="x:img">
<fo:block break-after="page">
<fo:external-graphic scaling="uniform" text-align="center"
width="18cm">
  <xsl:attribute name="height"><xsl:value-of
select="(@height div 400) * 12"/>cm</xsl:attribute>
<xsl:attribute name="content-height"><xsl:value-of
select="@height"/>px</xsl:attribute>
<xsl:attribute name="content-width"><xsl:value-of
select="@width"/>px</xsl:attribute>
<xsl:attribute name="src"><xsl:value-of
select="concat($baseHref, @src)"/></xsl:attribute>
</fo:external-graphic>
</fo:block>
</xsl:template>
<xsl:template match="xSurprisedl/x:li">
  <fo:block><xsl:apply-templates /></fo:block>
</xsl:template>
<xsl:template match="xSurprisedl/x:li/x:ul/x:li">
  <fo:block margin-left="2cm"><xsl:apply-templates /></fo:block>
</xsl:template>
<xsl:template match="x:hr">
  <fo:block break-after="page" />
</xsl:template>
<!-- <xsl:template match="x:p"/> -->
<xsl:template match="x:h1"/>
<xsl:template match="x:h6"/>
<xsl:template match="x:head"/>
<xsl:template match="x:script"/>
<xsl:template match="//*[@class='pdfignore']"/>
<xsl:template match="x:div[@class='nocss']"/>
<xsl:template match="x:div[@id='heading']"/>
<xsl:template match="x:div[@id='menu']"/>
<xsl:template match="x:div[@id='validation']"/>
<xsl:template match="x:div[@id='footer']"/>
</xsl:stylesheet>


help! free cakes to whoever can point me in the right direction Very Happy



--


x theSpaceGirl (miranda)

# lead designer @ <a style='text-decoration: underline;' href="http://www.dhnewmedia.com" target="_blank">http://www.dhnewmedia.com</a> #
# remove NO SPAM to email, or use form on website #<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: XSLT expert? How to apply filters :/ I'm stuck! 
Back to top
Login to vote
nothespacegirl

External


Since: Aug 11, 2004
Posts: 607



(Msg. 2) Posted: Fri Dec 03, 2004 8:35 am
Post subject: Re: XSLT expert? How to apply filters :/ I'm stuck! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

SpaceGirl wrote:

<snip hopelessness>

Nevermind! Found a work around Smile

--


x theSpaceGirl (miranda)

# lead designer @ http://www.dhnewmedia.com #
# remove NO SPAM to email, or use form on website #

 >> Stay informed about: XSLT expert? How to apply filters :/ I'm stuck! 
Back to top
Login to vote
usenet

External


Since: Sep 14, 2004
Posts: 1119



(Msg. 3) Posted: Fri Dec 03, 2004 9:35 am
Post subject: Re: XSLT expert? How to apply filters :/ I'm stuck! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

SpaceGirl wrote:

 > Nevermind! Found a work around Smile

Is this a /solution/ that will work each time, or did you *really* mean
a /workaround/ that is guaranteed to break if you adapt it for another
situation? Smile

--
Dylan Parry
<a style='text-decoration: underline;' href="http://webpageworkshop.co.uk" target="_blank">http://webpageworkshop.co.uk</a> -- FREE Web tutorials and references<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: XSLT expert? How to apply filters :/ I'm stuck! 
Back to top
Login to vote
nothespacegirl

External


Since: Aug 11, 2004
Posts: 607



(Msg. 4) Posted: Fri Dec 03, 2004 11:35 am
Post subject: Re: XSLT expert? How to apply filters :/ I'm stuck! [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Dylan Parry wrote:
 > SpaceGirl wrote:
 >
  >> Nevermind! Found a work around Smile
 >
 >
 > Is this a /solution/ that will work each time, or did you *really* mean
 > a /workaround/ that is guaranteed to break if you adapt it for another
 > situation? Smile
 >

The solution was to change the pages, not the XSLT Smile So long as someone
doesn't break the pages, I have nothing to worry about Very Happy

--


x theSpaceGirl (miranda)

# lead designer @ <a style='text-decoration: underline;' href="http://www.dhnewmedia.com" target="_blank">http://www.dhnewmedia.com</a> #
# remove NO SPAM to email, or use form on website #<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: XSLT expert? How to apply filters :/ I'm stuck! 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting and Web Master Forums (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]