Subject: Re: [xsl] Entity Questions From: "Luke Shannon" <lshannon@xxxxxxxxxxxxxxx> Date: Mon, 17 Jan 2005 18:50:46 -0500 |
Reading is a good idea. Someone just gave me Jeni Tennison's book. Once I get past this current snag I definetily need to spend some time reading. Here is a complete example: XML (not the whole document): <?xml version="1.0" encoding="UTF-8"?> <KCX PAGE="-1" PAGE_LENGTH="-1" ROOT="section4 <DATA> <VERSION> <ITEM NAME="TEXT1" TYPE="text">Hurricanes owner feels NHL season is gone</ITEM> <ITEM NAME="TEXT2" TYPE="text"> <B>The both sides are so greedy!</B> <P>I can't even afford to go see a game!</P> </ITEM> </VERSION> XSL: I have only the templates involved in the creation of the document so it is easier to trace. Each template is in a seperate file. <xsl:template match="*" mode="_KCXFILE_"> <!-- fo root: all document properties go inside this tag --> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!-- configure the page attributes --> <fo:layout-master-set> <fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm"> <fo:region-before extent="3.5cm"/> <fo:region-body margin-top="2cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <!-- ouput the content --> <fo:page-sequence master-reference="simple"> <fo:static-content flow-name="xsl-region-before"> <fo:block> <fo:external-graphic src="url(file:///images/topbanner/mainlogo.gif)" space-after="1cm"/> </fo:block> </fo:static-content> <xsl:call-template name="s1_pdf"/> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template name="s1_pdf"> <!-- text 1 --> <fo:flow flow-name="xsl-region-body"> <fo:block font-family="Helvetica" font-size="12pt" font-weight="bold" break-after="auto" space-after="10pt" text-align="left"> <xsl:call-template name="text_display_and_edit"> <xsl:with-param name="text_number" select="number('1')" /> </xsl:call-template> </fo:block> <!-- text 2 --> <fo:block font-family="Helvetica" font-size="12pt" font-weight="normal" text-align="left"> <xsl:call-template name="text_display_and_edit"> <xsl:with-param name="text_number" select="number('2')" /> </xsl:call-template> </fo:block> </fo:flow> </xsl:template> <!-- the next three templates are in the same file --> <!-- the output type for this file is <xsl:output method="xml" media-type="text/html"/> --> <xsl:template name="text_display_and_edit"> <xsl:param name="text_number" /> <xsl:param name="textname" select="concat('TEXT',$text_number)" /> <xsl:if test="DATA/VERSION/ITEM[@NAME=$textname] !=''" > <xsl:value-of select="DATA/VERSION/ITEM[@NAME=$textname]"/> </xsl:if> </xsl:template> <xsl:template match="P"> <fo:inline> <xsl:apply-templates/> </fo:inline> </xsl:template> <xsl:template match="B"> <fo:inline font-weight="bold"> <xsl:apply-templates/> </fo:inline> </xsl:template> Desired Document: <?xml version="1.0" encoding="UTF-8"?> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master margin-right="2.5cm" margin-left="2.5cm" margin-bottom="2cm" margin-top="1cm" page-width="21cm" page-height="29.7cm" master-name="simple"> <fo:region-before extent="3.5cm"/> <fo:region-body margin-top="2cm"/> <fo:region-after extent="1.5cm"/> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="simple"> <fo:static-content flow-name="xsl-region-before"> <fo:block text-align="left" space-after="10pt" break-after="auto" font-weight="bold" font-size="12pt" font-family="Arial"> Hurricanes owner feels NHL season is gone</fo:block> <fo:block text-align="left" space-after="10pt" break-after="auto" font-weight="normal" font-size="12pt" font-family="Arial"> <fo:inline font-weight="bold">The both sides are so greedy!</fo:inline> <fo:inline>I can't even afford to go see a game!</fo:inline> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> Thanks, Luke ----- Original Message ----- From: "Michael Kay" <mike@xxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, January 17, 2005 6:19 PM Subject: RE: [xsl] Entity Questions > > > > I tested adding the match="P" template. I didn't replace > > anything. I think > > this might be because I changed the output method to xml to deal with > > entities like > > > > I am thinking the <P> tags are now <P> so the template > > is not matching > > them. I am adding some logging to verify this, if this is the > > case I may > > need to rethink things. > > Try to reduce the size of the problem, and post a complete specimen > including source XML, desired result, and stylesheet. Then we can see where > you're going wrong. You're not grasping some of the concepts: you're still > talking about tags rather than nodes, and thinking of the input and output > as text rather than trees. It might be a good idea to do some reading. > > Michael Kay > http://www.saxonica.com/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Entity Questions, Michael Kay | Thread | Re: [xsl] Entity Questions, Luke Shannon |
RE: [xsl] Entity Questions, Michael Kay | Date | [xsl] Group data by child node, Eric Gillingham |
Month |