Background-image not displays in xsl fo with Relative Path URL - image
I am trying to create a pdf using xsl-fo where the background image is being used. I have set up the relative path as follows:
background-image = "url('../themes/images/logo.gif')"
When I give absolute path like background-image="C://Images/logo.gif", it worked.
but when I use url to take it relatively in the server, it is not working.
Below is my scenario.
XML:
<?xml version="1.0" encoding="iso-8859-1"?>
<form-data>
<field>
<name>txtFirstName</name>
<value>ABC</value>
</field>
<field>
<name>txtLastName</name>
<value>XYZ</value>
</field>
</form-data>
XSL-FO ( to get the Pdf )
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="SPM_Name" page-height="29.7cm" page-width="21cm" margin-top="1.2cm" margin-bottom="1.2cm" margin-left="1.75cm" margin-right="1.75cm">
<fo:region-body margin-top="0.5cm" />
<fo:region-before extent="0.5cm" />
<fo:region-after extent="1cm" />
</fo:simple-page-master>
<fo:page-sequence-master master-name="PSM_Name">
<fo:single-page-master-reference master-reference="SPM_Name" />
</fo:page-sequence-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="PSM_Name" initial-page-number="1">
<fo:static-content flow-name="xsl-region-before">
<fo:block text-align="end" font-size="10pt" font-family="serif" line-height="14pt">
Page
<fo:page-number />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block background-image="url('http://localhost:9081/resources/themes/images/Logo1.gif')" background-position="right" background-color="transparent" >
</fo:block>
<fo:block font-size="20pt" text-align="center" font-family="sans-serif" line-height="20pt" space-after.optimum="15pt" padding-top="18pt">Income Tax Form</fo:block>
<fo:table table-layout="fixed" width="100%" border-collapse="separate">
<fo:table-column column-width="50%" />
<fo:table-column column-width="50%" />
<fo:table-header text-align="center">
<fo:table-row>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block font-weight="solid">Questions</fo:block>
</fo:table-cell>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block font-weight="solid">Form Inputs</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body text-align="center">
<fo:table-row>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block>Your First Name</fo:block>
</fo:table-cell>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block>
<xsl:value-of select="//field/value[../name/text() = 'txtFirstName']" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block>Your Last Name</fo:block>
</fo:table-cell>
<fo:table-cell padding="6pt" border="0.5pt solid black" wrap-option="wrap" keep-together.within-column="always">
<fo:block>
<xsl:value-of select="//field/value[../name/text() = 'txtLastName']" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
As you say in the comments that you don't get any "Image not found" warning, I think there is nothing wrong with the image URL.
Your stylesheet puts the image as background of an empty fo:block:
<fo:block background-image="url('http://localhost:9081/resources/themes/images/Logo1.gif')"
background-position="right" background-color="transparent" >
</fo:block>
An empty fo:block produces a single block area whose height is 0pt, so its background is not visible.
If your image must be the background for the whole page, use an absolute positioned fo:block-container instead:
<fo:block-container position="absolute" height="25cm"
background-image="url('http://localhost:9081/resources/themes/images/Logo1.gif')"
background-position="right" background-color="transparent" >
<fo:block/>
</fo:block-container>
the height attribute sets the height of the generated area, i.e. the area which will have the desired background (use the height you want)
you can also use the properties background-repeat and background-position-horizontal to control repetion and position of the image
the empty fo:block inside the container is needed if your FO processor is strict about validation (Apache FOP is, and it would give a validation exception if the block-container were empty)
Related
Apache FOP image not hide
I set margin-right:1.0in. The last column show the image but hide the text. I know the last column is overflow, but why the the image is showing but the text not? How to hide all of the content include the image? The file content is like below: <?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 page-height="8.5in" page-width="14.0in" margin-left="0.1in" margin-right="1.0in" margin-bottom="0.2in" margin-top="0.2in" master-name="all-pages"> <fo:region-body region-name="xsl-region-body" margin-bottom="0.1in" margin-top="0.1in"/> <fo:region-before extent="0.1in" region-name="xsl-region-header"/> <fo:region-after extent="0.1in" region-name="xsl-region-footer"/> </fo:simple-page-master> <fo:page-sequence-master master-name="reportSeqn1PageMasterParametersSet"> <fo:repeatable-page-master-reference master-reference="all-pages"/> </fo:page-sequence-master> <fo:page-sequence-master master-name="reportSeqn1PageMasterColumnSet1"> <fo:repeatable-page-master-reference master-reference="all-pages"/> </fo:page-sequence-master> <fo:page-sequence-master master-name="reportSeqn1PageMasterColumnSet2"> <fo:repeatable-page-master-reference master-reference="all-pages"/> </fo:page-sequence-master> <fo:page-sequence-master master-name="reportSeqn1PageMasterImageSet"> <fo:repeatable-page-master-reference master-reference="all-pages"/> </fo:page-sequence-master> </fo:layout-master-set> <fo:page-sequence force-page-count="no-force" master-reference="reportSeqn1PageMasterColumnSet1" initial-page-number="1"> <fo:static-content flow-name="xsl-region-header"> <fo:block font-family="Arial" font-size="8pt" text-align="end">Dec 07, 2016</fo:block> <fo:block font-family="Arial" font-size="8pt" text-align="end">05:55 PM</fo:block> <fo:block font-weight="normal" font-family="Arial" font-size="12pt" text-align="center" text-decoration="none">Finance Integration Tasks</fo:block> </fo:static-content> <fo:static-content flow-name="xsl-region-footer"> <fo:block font-family="Arial" font-size="8pt" text-align="end"> Page <fo:page-number/> Column set 1 of 2</fo:block> </fo:static-content> <fo:flow flow-name="xsl-region-body"> <fo:block-container width="1653.2640000000001pt"> <fo:block font-family="Arial" font-size="8pt" margin-top="5pt"> <fo:table table-layout="fixed" width="1653.2640000000001pt"> <fo:table-column column-number="1" column-width="84.43636363636364pt"/> <fo:table-column column-number="2" column-width="84.43636363636364pt"/> <fo:table-column column-number="3" column-width="84.43636363636364pt"/> <fo:table-column column-number="4" column-width="84.43636363636364pt"/> <fo:table-column column-number="5" column-width="84.43636363636364pt"/> <fo:table-column column-number="6" column-width="84.43636363636364pt"/> <fo:table-column column-number="7" column-width="84.43636363636364pt"/> <fo:table-column column-number="8" column-width="84.43636363636364pt"/> <fo:table-column column-number="9" column-width="84.43636363636364pt"/> <fo:table-column column-number="10" column-width="84.43636363636364pt"/> <fo:table-column column-number="11" column-width="84.43636363636364pt"/> <fo:table-column column-number="12" column-width="724.464pt"/> <fo:table-body> <fo:table-row> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)"># of Critical Issues</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Description</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)"># of Other Issues</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test1</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test2</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test3</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test4</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test5</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test6</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(51,102,153)"> <fo:block text-align="start" color="rgb(255,255,255)">Test7</fo:block> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(255,255,255)" border-top-color="rgb(255,255,255)" border-right-color="rgb(255,255,255)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block text-align="start" color="rgb(255,255,255)">title</fo:block> </fo:table-cell> </fo:table-row> <fo:table-row> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="#ffff00"> <fo:block-container > <fo:block font-family="Arial" color="Black" text-align="left"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Black" font-weight="normal" font-style="normal" text-decoration="none">Tin Can</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="Red" text-align="left" font-weight="bold"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Red" font-weight="bold" font-style="normal" text-decoration="none">ABCD</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="Black" text-align="center"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Black" font-weight="normal" font-style="normal" text-decoration="none">4</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="Black" text-align="right"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Black" font-weight="normal" font-style="normal" text-decoration="none">19</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="Black" text-align="left"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Black" font-weight="normal" font-style="normal" text-decoration="none">Tin Can</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="#000000" text-align="left">ABCD</fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="#000000" text-align="left">Tin Can</fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="#000000" text-align="left">ABCD</fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="#000000" text-align="left">Tin Can</fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="#000000" text-align="left">ABCD</fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(200,215,227)" border-top-color="rgb(200,215,227)" border-right-color="rgb(200,215,227)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="Black" text-align="right"> <fo:inline xmlns:exslt="http://exslt.org/common" color="Black" font-weight="normal" font-style="normal" text-decoration="none">Tin Can</fo:inline> </fo:block> </fo:block-container> </fo:table-cell> <fo:table-cell padding="2pt" border-bottom-color="rgb(255,255,255)" border-top-color="rgb(255,255,255)" border-right-color="rgb(255,255,255)" border-left-color="rgb(200,215,227)" border-style="solid" border-width="0.25pt" background-color="rgb(255,255,255)"> <fo:block-container > <fo:block font-family="Arial" color="rgb(255,255,255)" text-align="left"> <fo:inline xmlns:exslt="http://exslt.org/common" font-weight="normal" font-style="normal">ABCD</fo:inline> <fo:external-graphic src="url('file:///C:/Users/sujianrong/Desktop/fop-2.1-bin.tar/fop-2.1-bin/fop-2.1/examples/fo/graphics/fop.jpg')" content-width="10pt" /> </fo:block> </fo:block-container> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:block> </fo:block-container> <fo:block id="reportSeqn1last-pageColumnSet2"/> </fo:flow> </fo:page-sequence> </fo:root>
Add overflow="hidden" to the fo:region-body. See https://www.w3.org/TR/xsl11/#overflow
Apache FOP Displaying ### instead of Arabic
I am new to Apache-FOP. I use this to generate PDF documet from a XML input. I have created XSL for my input XML and getting ### values instead of Arabic text. Can any one please point out the mistake? I have set of fonts but still I cannot get the right result. XML Input: <TestData> <TestXML> <Name>Sathish நன்றி</Name> <Dept>Channels</Dept> <Year>2016</Year> </TestXML> <TestXML> <Name>Sathish dėkoju</Name> <Dept>Channels</Dept> <Year>2016</Year> </TestXML> <TestXML> <Name>Sathish благодаря</Name> <Dept>Channels</Dept> <Year>2016</Year> </TestXML> <TestXML> <Name>Sathish شكر</Name> <Dept>Channels</Dept> <Year>2016</Year> </TestXML> </TestData> XSL: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0"> <xsl:template match="/"> <fo:root> <fo:layout-master-set> <fo:simple-page-master master-name="A4-portrait" page-height="29.7cm" page-width="21.0cm" margin="2cm"> <fo:region-body /> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="A4-portrait"> <fo:flow flow-name="xsl-region-body"> <fo:block> <fo:table table-layout="fixed" width="100%"> <fo:table-header> <fo:table-row background-color="#c0c0c0" height="0.59cm"> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.0cm" margin-right="0.14cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left">Name</fo:block> </fo:table-cell> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.51cm" margin-right="0.16cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left">Department</fo:block> </fo:table-cell> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.0cm" margin-right="2.65cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left">Year</fo:block> </fo:table-cell> </fo:table-row> </fo:table-header> <fo:table-body> <xsl:for-each select="TestData/TestXML"> <fo:table-row background-color="#ffffff" height="0.57cm"> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.0cm" margin-right="0.14cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left"> <xsl:value-of select="Name" /> </fo:block> </fo:table-cell> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.0cm" margin-right="0.14cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left"> <xsl:value-of select="Dept" /> </fo:block> </fo:table-cell> <fo:table-cell number-columns-spanned="1"> <fo:block margin-left="0.0cm" margin-right="0.14cm" margin-top="0.0cm" font-size="10pt" color="#000000" text-align="left"> <xsl:value-of select="Year" /> </fo:block> </fo:table-cell> </fo:table-row> </xsl:for-each> </fo:table-body> </fo:table> </fo:block> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> </xsl:stylesheet> myConf.xconf: <fop> <renderers> <renderer mime="application/pdf"> <fonts> <auto-detect/> </fonts> </renderer> </renderers> </fop> WARNINGS: 12 Aug, 2016 4:47:31 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0xba8) not available in font "Helvetica". 12 Aug, 2016 4:47:31 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0xba9) not available in font "Helvetica". 12 Aug, 2016 4:47:31 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0xbcd) not available in font "Helvetica". 12 Aug, 2016 4:47:31 PM org.apache.fop.events.LoggingEventListener processEvent WARNING: Glyph "?" (0xbb1) not available in font "Helvetica". Result: Sathish ##### Channels 2016 Sathish d#koju Channels 2016 Sathish ######### Channels 2016 Result Image
BI Publisher Ring Chart Thickness
I am relatively new to BI Publisher and I have to date only worked with line and bar charts. I am working on a report that uses Ring Charts, and the default thickness of the chart is too much. I want it to look like a hoola hoop and not a doughnut, as below. But I dont know what node to change in the XML, can someone advise? Chart Currently looks like this: I would like it to look like this: Any help is greatly appreciated. Thanks Chart Code <Graph seriesEffect="SE_NONE" graphType="RING"> <LegendArea visible="false" /> <SeriesItems> <Series id="0" color="#447A27" /> <Series id="1" color="#96b27f" /> <Series id="2" color="#c4c5c7" /> <Series id="3" color="#EA4848" /> <Series id="4" color="#C41C24" /> </SeriesItems> <SliceLabel visible="false"> <ViewFormat decimalDigit="0" decimalDigitUsed="true" /> </SliceLabel> <LocalGridData colCount="1" rowCount="{count(.//DATASET[condition='Test'])}"> <RowLabels> <xsl:for-each select=".//DATASET[condition='Test']" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <Label> <xsl:value-of select="QUALITY_LEVEL" /> </Label> </xsl:for-each> </RowLabels> <DataValues> <xsl:for-each select=".//DATASET[condition='Test']" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <RowData> <Cell> <xsl:value-of select="COUNT" /> </Cell> </RowData> </xsl:for-each> </DataValues> </LocalGridData> <RingTotalLabel> <GraphFont size="50" fontColor="#c4c5c7" /> </RingTotalLabel> </Graph>
XSL Picture in table
I do read the relevant posts, but my code is still not working. I just want to add a avatar (png) to the players in my table. My HTML: <root version="2.0"> <game> <players> <nickname>thebeast</nickname> <avatar><img src="/img/thebeast.png" height="30" width="30"></img></avatar> <sum>220</sum> </players> <players> <nickname>snowman</nickname> <avatar><img src="/img/snowman.png" height="30" width="30"></img</avatar> <sum>360</sum> </players> </game> </root> My table in xsl: <table align = "center" border="transparent"> <tr><th>Nr.</th><th>Nickname</th><th>Collected <br/>Points</th></tr> <xsl:for-each select = "//players"> <xsl:sort select = "sum" data-type="number" order="descending"/> <tr> <td><xsl:number value = "position()" format = "1."/></td> <td><xsl:value-of select = "nickname"/></td> <td><xsl:value-of select = "sum"/></td> <td> <img> <xsl:attribute name="src"> <xsl:value-of select="/img" /> </xsl:attribute> </img> </td> </tr> </xsl:for-each> </table>
Instead of: <img> <xsl:attribute name="src"> <xsl:value-of select="/img" /> </xsl:attribute> </img> try: <img> <xsl:attribute name="src"> <xsl:value-of select="avatar/img/#src" /> </xsl:attribute> </img> or, in short: <img src="{avatar/img/#src}"></img> Or, if you want to preserve the dimensions: <xsl:copy-of select="avatar/img"/>
How to access variable as parameter from another template XSLT
Hello I have one problem, I have 2 variables(min_value and max_value) they are in different templates MIN and MAX, in MAX I want to calculate the difference between max_value and min_value but the result is NAN since min_value values are not transferred from one template to another. <xsl:template match="MAX"> <xsl:param name= "min_value"/> <xsl:variable name="max_value" select= "SHARE_RATE"/> <span class="max_rate"> MAX: <xsl:apply-templates select="SHARE_RATE"/> </span> <br/> <span class= "diff"> Diff: (<xsl:value-of select="$max_value - $min_value"/>) </span> </xsl:template> <xsl:template match="MIN"> <xsl:variable name="min_value" select="SHARE_RATE"/> <span class="SHARE_RATE"> MIN: <xsl:apply-templates select="SHARE_RATE"/> </span> <xsl:apply-templates select="MAX"> <xsl:with-param name="min_value" select= "$min_value"/> </xsl:apply-templates> </xsl:template> UPDATE <page shareid="%" min_rate="%" max_rate="%" skip="0"> <TRANSACTIONS> <MIN num="1"> <SHAREID>0</SHAREID> <SHARE_RATE>1200</SHARE_RATE> </MIN> <MIN num="2"> <SHAREID>1</SHAREID> <SHARE_RATE>4200</SHARE_RATE> </MIN> <MIN num="3"> <SHAREID>2</SHAREID> <SHARE_RATE>1600</SHARE_RATE> </MIN> <MIN num="4"> <SHAREID>3</SHAREID> <SHARE_RATE>6100</SHARE_RATE> </MIN> <MIN num="5"> <SHAREID>4</SHAREID> <SHARE_RATE>550</SHARE_RATE> </MIN> <MIN num="6"> <SHAREID>5</SHAREID> <SHARE_RATE>420</SHARE_RATE> </MIN> <MIN num="7"> <SHAREID>6</SHAREID> <SHARE_RATE>2000</SHARE_RATE> </MIN> </TRANSACTIONS> <TRANSACTIONS> <MAX num="1"> <SHAREID>0</SHAREID> <SHARE_RATE>2100</SHARE_RATE> </MAX> <MAX num="2"> <SHAREID>1</SHAREID> <SHARE_RATE>5200</SHARE_RATE> </MAX> <MAX num="3"> <SHAREID>2</SHAREID> <SHARE_RATE>2000</SHARE_RATE> </MAX> <MAX num="4"> <SHAREID>3</SHAREID> <SHARE_RATE>7000</SHARE_RATE> </MAX> <MAX num="5"> <SHAREID>4</SHAREID> <SHARE_RATE>1000</SHARE_RATE> </MAX> <MAX num="6"> <SHAREID>5</SHAREID> <SHARE_RATE>2520</SHARE_RATE> </MAX> <MAX num="7"> <SHAREID>5</SHAREID> <SHARE_RATE>2520</SHARE_RATE> </MAX> </TRANSACTIONS> </page> UPDATE 2 <?xml version="1.0" encoding="ISO-8859-2"?> <?xml-stylesheet type="text/xsl" href="share.xsl"?> <page connection="labor" xmlns:xsql="urn:oracle-xsql" shareid="%" min_rate= "%" max_rate= "%" skip="0"> <xsql:query rowset-element="TRANSACTIONS" row-element="MIN" skip-rows="{#skip}" max-rows="{#max-rows}" bind-params="shareid min_rate "> SELECT f77inq.shares.shareid, A.share_rate FROM f77inq.trans A INNER JOIN f77inq.shares ON A.shareid = f77inq.shares.shareid WHERE A.shareid LIKE ? AND A.share_rate= ( SELECT MIN(share_rate) FROM f77inq.trans B WHERE B.shareid = A.shareid ) AND A.share_rate LIKE? </xsql:query> <xsql:query rowset-element="TRANSACTIONS" row-element="MAX" skip-rows="{#skip}" max-rows="{#max-rows}" bind-params="shareid"> SELECT f77inq.shares.shareid, A.share_rate FROM f77inq.trans A INNER JOIN f77inq.shares ON A.shareid = f77inq.shares.shareid WHERE A.shareid LIKE ? AND A.share_rate= ( SELECT MAX(share_rate) FROM f77inq.trans B WHERE B.shareid = A.shareid ) </xsql:query> </page>
I would suggest you use a key to link the MIN and MAX values, based on a common SHAREID. Here's an example that uses XML output for better clarity: XSLT 1.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:key name="max" match="MAX" use="SHAREID" /> <xsl:template match="/page"> <root> <xsl:apply-templates select="TRANSACTIONS/MIN"/> </root> </xsl:template> <xsl:template match="MIN"> <xsl:variable name="id" select="SHAREID" /> <xsl:variable name="min" select="SHARE_RATE" /> <xsl:variable name="max" select="key('max', $id)/SHARE_RATE" /> <share id="{$id}"> <min><xsl:value-of select="$min"/></min> <max><xsl:value-of select="$max"/></max> <diff><xsl:value-of select="$max - $min"/></diff> </share> </xsl:template> </xsl:stylesheet> Applied to your example input, the result is: <?xml version="1.0" encoding="UTF-8"?> <root> <share id="0"> <min>1200</min> <max>2100</max> <diff>900</diff> </share> <share id="1"> <min>4200</min> <max>5200</max> <diff>1000</diff> </share> <share id="2"> <min>1600</min> <max>2000</max> <diff>400</diff> </share> <share id="3"> <min>6100</min> <max>7000</max> <diff>900</diff> </share> <share id="4"> <min>550</min> <max>1000</max> <diff>450</diff> </share> <share id="5"> <min>420</min> <max>2520</max> <diff>2100</diff> </share> <share id="6"> <min>2000</min> <max>2520</max> <diff>520</diff> </share> </root>
ok, what I understand is, that you want to match MIN/MAX values with the same SHAREID. In this case the following xslt might do what you need: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:strip-space elements="*"/> <xsl:template match="MAX"> <xsl:variable name="id" select="SHAREID"/> <!-- or '0' handles the case where no coresponding MIN/SHARE_RATE is found --> <xsl:variable name="min_value" select="//MIN[SHAREID=$id]/SHARE_RATE or '0'"/> <xsl:variable name="max_value" select= "SHARE_RATE"/> <span class="max_rate"> MAX: <xsl:value-of select="$max_value"/> </span> <br/> <span class= "diff"> Diff: (<xsl:value-of select="$max_value - $min_value"/>) </span> </xsl:template> <!-- MAX does it all, so ignore output of MIN --> <xsl:template match="MIN"/> <xsl:template match="*"> <xsl:apply-templates/> </xsl:template> </xsl:stylesheet>