xsl:for-each-group positional grouping flat xml to hierarchical - xpath

I have a flat xml file that needs to be converted to hierarchical. I used the nested grouping idea from here xsl:for-each-group help needed. It's working for the most part except for a couple of issues:
1) The elements root1 and root2 are not showing up.
2) The location of element NFActy is incorrect. The first NFActy should be between the 2 Rot elements.
3) The Duty & NFActy elements are treated as one group for calculating the SequenceCount.
4) For Leg elements each set of Leg elements within one duty should be grouped for SequenceCount for leg elements.
Any help is really appreciated.
Thanks.
Input XML
<root>
<root1>1234</root1>
<root2>5678</root2>
<Schedule>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
</Schedule>
<Rot>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
</Rot>
<Duty>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
</Duty>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<NFActy>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</NFActy>
<Rot>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
</Rot>
<Duty>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
</Duty>
<Leg>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</Leg>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<NFActy>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</NFActy>
Desired Output XML
<root>
<root1>1234</root1>
<root2>5678</root2>
<Schedule>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
<Rot>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
<Duty>
<SequenceCount>1</SequenceCount>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
<Leg>
<SequenceCount>1</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<Leg>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
</Duty>
</Rot>
<NFActy>
<SequenceCount>2</SequenceCount>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</NFActy>
<Rot>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
<Duty>
<SequenceCount>3</SequenceCount>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
<Leg>
<SequenceCount>1</SequenceCount>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</Leg>
<Leg>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
/Leg>
</Duty>
</Rot>
<NFActy>
<SequenceCount>4</SequenceCount>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</NFActy>
</Schedule>
My XSL
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="fn" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"
exclude-result-prefixes="xs fn">
<xsl:output indent="yes" />
<xsl:template match="/">
<xsl:for-each-group select="*" group-starting-with="root">
<root>
<xsl:for-each-group select="*" group-starting-with="*[name(.)='Schedule']">
<xsl:choose>
<xsl:when test="name(.)='Schedule'">
<Schedule>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='Rot']">
<xsl:choose>
<xsl:when test="name(.)='Rot'">
<Rot>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='Duty']">
<xsl:choose>
<xsl:when test="name(.)='Duty'">
<Duty>
<xsl:element name="SequenceCount"><xsl:number count="Duty|NFActy" level="any"/></xsl:element>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='Leg']">
<xsl:choose>
<xsl:when test="name(.)='Leg'">
<Leg>
<xsl:element name="SequenceCount"><xsl:number value="position() - 1"/></xsl:element>
<xsl:apply-templates />
</Leg>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</Duty>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</Rot>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='NFActy']">
<xsl:choose>
<xsl:when test="name(.)='NFActy'">
<NFActy>
<xsl:element name="SequenceCount"><xsl:number count="Duty|NFActy" level="any"/></xsl:element>
<xsl:apply-templates />
</NFActy>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</Schedule>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</root>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>

Here is my edit of your code, you need to make sure you process all elements at the same time and not as you had with sequential for-each-group.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"
exclude-result-prefixes="xs">
<xsl:output indent="yes" />
<xsl:template match="root">
<xsl:copy>
<xsl:for-each-group select="*" group-starting-with="Schedule">
<xsl:choose>
<xsl:when test="self::Schedule">
<Schedule>
<xsl:apply-templates />
<xsl:for-each-group select="current-group() except ." group-starting-with="Rot | NFActy">
<xsl:choose>
<xsl:when test="self::Rot | self::NFActy">
<xsl:copy>
<xsl:if test="self::NFActy">
<SequenceCount><xsl:number count="Duty | NFActy" level="any"/></SequenceCount>
</xsl:if>
<xsl:apply-templates />
<xsl:for-each-group select="current-group() except ." group-starting-with="Duty">
<xsl:choose>
<xsl:when test="self::Duty">
<xsl:copy>
<SequenceCount><xsl:number count="Duty | NFActy" level="any"/></SequenceCount>
<xsl:apply-templates />
<xsl:for-each-group select="current-group() except ." group-starting-with="Leg">
<xsl:choose>
<xsl:when test="self::Leg">
<Leg>
<SequenceCount><xsl:number value="position()"/></SequenceCount>
<xsl:apply-templates />
</Leg>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</Schedule>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
When I apply above stylesheet with Saxon 9.5 to the input
<root>
<root1>1234</root1>
<root2>5678</root2>
<Schedule>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
</Schedule>
<Rot>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
</Rot>
<Duty>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
</Duty>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<NFActy>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</NFActy>
<Rot>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
</Rot>
<Duty>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
</Duty>
<Leg>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</Leg>
<Leg>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<NFActy>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</NFActy>
</root>
I get the result
<root>
<root1>1234</root1>
<root2>5678</root2>
<Schedule>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
<Rot>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
<Duty>
<SequenceCount>1</SequenceCount>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
<Leg>
<SequenceCount>1</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
<Leg>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
</Duty>
</Rot>
<NFActy>
<SequenceCount>2</SequenceCount>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</NFActy>
<Rot>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
<Duty>
<SequenceCount>3</SequenceCount>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
<Leg>
<SequenceCount>1</SequenceCount>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</Leg>
<Leg>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</Leg>
</Duty>
</Rot>
<NFActy>
<SequenceCount>4</SequenceCount>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</NFActy>
</Schedule>
</root>

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

xslt sorting for some part of a file

I'm very new to XSLT, and I want to sort a part of XML file.(keeping all the file data)
Here's the file :
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test.xsd">
<SchemaVersion>1.0</SchemaVersion>
<Header>### uVision Project, (C) Keil Software</Header>
<Extensions>
<cExt>*.c</cExt>
<aExt>*.s*; *.src; *.a*</aExt>
<oExt>*.obj</oExt>
<lExt>*.lib</lExt>
<tExt>*.txt; *.h; *.inc</tExt>
<pExt>*.plm</pExt>
<CppX>*.cpp</CppX>
<nMigrate>0</nMigrate>
</Extensions>
<DateTime>
<dwLowDateTime>0</dwLowDateTime>
<dwHighDateTime>0</dwHighDateTime>
</DateTime>
<Target>
<TargetName>LYNX_XERIUS_APRR_CPU2006_0091</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<TargetOption>
<OPTTT>
<gFlags>0</gFlags>
</OPTTT>
<AAA>
<SetRegEntry>
<Number>0</Number>
</SetRegEntry>
</AAA>
<Breakpoint>
<Bp>
<Number>0</Number>
</Bp>
<Bp>
<Number>1</Number>
</Bp>
<Bp>
<Number>2</Number>
</Bp>
<Bp>
<Number>3</Number>
</Bp>
<Bp>
<Number>4</Number>
</Bp>
</Breakpoint>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
</DebugFlag>
<LintExecutable></LintExecutable>
</TargetOption>
</Target>
<Target>
<TargetName>Debug</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<TargetOption>
<OPTTT>
<gFlags>0</gFlags>
</OPTTT>
<AAA>
<SetRegEntry>
<Number>0</Number>
</SetRegEntry>
</AAA>
<Breakpoint>
<Bp>
<Number>0</Number>
</Bp>
<Bp>
<Number>1</Number>
</Bp>
<Bp>
<Number>2</Number>
</Bp>
<Bp>
<Number>3</Number>
</Bp>
<Bp>
<Number>4</Number>
</Bp>
</Breakpoint>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
</DebugFlag>
<LintExecutable></LintExecutable>
</TargetOption>
</Target>
<Target>
<TargetName>LYNX_HERMES_APRR_SERIE_200</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<TargetOption>
<OPTTT>
<gFlags>0</gFlags>
</OPTTT>
<AAA>
<SetRegEntry>
<Number>0</Number>
</SetRegEntry>
</AAA>
<Breakpoint>
<Bp>
<Number>0</Number>
</Bp>
<Bp>
<Number>1</Number>
</Bp>
<Bp>
<Number>2</Number>
</Bp>
<Bp>
<Number>3</Number>
</Bp>
<Bp>
<Number>4</Number>
</Bp>
</Breakpoint>
<Tracepoint>
<THDelay>0</THDelay>
</Tracepoint>
<DebugFlag>
<trace>0</trace>
</DebugFlag>
<LintExecutable></LintExecutable>
</TargetOption>
</Target>
<Group>
<GroupName>::CMSIS</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
</Group>
</Project>
Here's my XSLT :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="urn:TestNamespace" >
<xsl:output indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match="text()[not(string-length(normalize-space()))]"/>
<xsl:template match="Project">
<xsl:copy>
<xsl:apply-templates select="Target">
<xsl:sort select="TargetName"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<!-- global template to copy everything that doesn't match the other templates -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I got a XML file sorted by TargetName as output, but with only Target nodes....
How can I setup the select case to keep the unfiltered nodes ?
I also tested with :
<xsl:copy>
<xsl:apply-templates select="#*"/>
<xsl:apply-templates select="Target">
<xsl:sort select="TargetName"/>
</xsl:apply-templates>
</xsl:copy>
In this case, all data is kept but there is no sorting ?
I will appreciate some explanation to improve my knowledge.
Best Regards
One approach is:
<xsl:template match="Project">
<xsl:copy>
<xsl:apply-templates select="node()">
<xsl:sort select="TargetName" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
Why is your solution not working:
<xsl:apply-templates select="Target">
You select only Target to apply further.
I would probably do this (using XSLT 2.0):
<xsl:template match="Project">
<xsl:copy>
<xsl:for-each-group select="*" group-adjacent="node-name()">
<xsl:apply-templates>
<xsl:sort select="TargetName"/>
</xsl:apply-templates>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
on the assumption that sorting groups of elements other than Target elements does no harm. But it would probably be cleaner to have a conditional (xsl:choose) inside the xsl:for-each-group so the sorting is only done when test="self::Target".

xsl:for-each-group positional grouping [duplicate]

This question already has an answer here:
xsl:for-each-group positional grouping flat xml to hierarchical
(1 answer)
Closed 8 years ago.
I have a flat xml file that needs to be converted to hierarchical. I used the nested grouping idea from here xsl:for-each-group help needed. It's working for the most part except for a couple of issues:
1) The elements root1 and root2 are not showing up.
2) The location of element level21 is incorrect. The first level21 with sequencecount=2 should be between the 2 level2 elements.
Any help is really appreciated.
Thanks.
Source XML
<root>
<root1>1234</root1>
<root2>5678</root2>
<level1>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
</level1>
<level2>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
</level2>
<level3>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
</level3>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level21>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</level21>
<level2>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
</level2>
<level3>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
</level3>
<level4>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</level4>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level21>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</level21>
Required Result XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<root1>1234</root1>
<root2>5678</root2>
<level1>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
<level2>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
<level3>
<SequenceCount>1</SequenceCount>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level21>
<SequenceCount>2</SequenceCount>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</level21>
<level2>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
<level3>
<SequenceCount>3</SequenceCount>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level21>
<SequenceCount>4</SequenceCount>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</level21>
</level1>
</root>
My XSL
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="fn" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0"
exclude-result-prefixes="xs fn">
<xsl:output indent="yes" />
<xsl:template match="/">
<xsl:for-each-group select="*" group-starting-with="root">
<root>
<xsl:for-each-group select="*" group-starting-with="*[name(.)='level1']">
<xsl:choose>
<xsl:when test="name(.)='level1'">
<level1>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='level2']">
<xsl:choose>
<xsl:when test="name(.)='level2'">
<level2>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='level3']">
<xsl:choose>
<xsl:when test="name(.)='level3'">
<level3>
<xsl:element name="SequenceCount"><xsl:number count="level3|level21" level="any"/></xsl:element>
<xsl:apply-templates />
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='level4']">
<xsl:choose>
<xsl:when test="name(.)='level4'">
<level4>
<xsl:element name="SequenceCount"><xsl:number value="position() - 1"/></xsl:element>
<xsl:apply-templates />
</level4>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</level3>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</level2>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
<xsl:for-each-group select="current-group()" group-starting-with="*[name(.)='level21']">
<xsl:choose>
<xsl:when test="name(.)='level21'">
<level21>
<xsl:element name="SequenceCount"><xsl:number count="level3|level21" level="any"/></xsl:element>
<xsl:apply-templates />
</level21>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</level1>
</xsl:when>
</xsl:choose>
</xsl:for-each-group>
</root>
</xsl:for-each-group>
</xsl:template>
<xsl:template match="node()">
<xsl:copy>
<xsl:apply-templates select="node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Current Output XML
<?xml version="1.0" encoding="UTF-8"?>
<root>
<level1>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
<level2>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
<level3>
<SequenceCount>1</SequenceCount>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level2>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
<level3>
<SequenceCount>3</SequenceCount>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level21>
<SequenceCount>2</SequenceCount>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</level21>
<level21>
<SequenceCount>4</SequenceCount>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</level21>
</level1>
</root>
I think the following stylesheet gives you the grouping you want:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mf="http://example.com/mf"
exclude-result-prefixes="xs mf">
<xsl:output indent="yes"/>
<xsl:function name="mf:group" as="node()*">
<xsl:param name="elements" as="element()*"/>
<xsl:param name="level" as="xs:integer"/>
<xsl:for-each-group select="$elements" group-starting-with="*[starts-with(local-name(), concat('level', $level))]">
<xsl:choose>
<xsl:when test="self::*[starts-with(local-name(), concat('level', $level))]">
<xsl:copy>
<xsl:if test="$level = (3, 4)">
<SequenceCount><xsl:value-of select="position()"/></SequenceCount>
</xsl:if>
<xsl:apply-templates/>
<xsl:sequence select="mf:group(current-group() except ., $level + 1)"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:function>
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<xsl:copy>
<xsl:sequence select="mf:group(*, 1)"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
For the SequenceCount element some values are as in your posted result sample, some are different, some are missing. Let's first establish whether the grouping is as you want it, then we can try to improve the sequence count value. You might want to explain in writing what that count refers to.
[edit]Based on your XSLT code I have added code to compute the SequenceNumber for the different levels, the complete stylesheet is now
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mf="http://example.com/mf"
exclude-result-prefixes="xs mf">
<xsl:output indent="yes"/>
<xsl:function name="mf:group" as="node()*">
<xsl:param name="elements" as="element()*"/>
<xsl:param name="level" as="xs:integer"/>
<xsl:for-each-group select="$elements" group-starting-with="*[starts-with(local-name(), concat('level', $level))]">
<xsl:choose>
<xsl:when test="self::*[starts-with(local-name(), concat('level', $level))]">
<xsl:copy>
<xsl:choose>
<xsl:when test="self::level3">
<SequenceCount><xsl:number count="level3 | level21"/></SequenceCount>
</xsl:when>
<xsl:when test="self::level4">
<SequenceCount><xsl:value-of select="position()"/></SequenceCount>
</xsl:when>
<xsl:when test="self::level21">
<SequenceCount><xsl:number count="level3|level21"/></SequenceCount>
</xsl:when>
</xsl:choose>
<xsl:apply-templates/>
<xsl:sequence select="mf:group(current-group() except ., $level + 1)"/>
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:function>
<xsl:template match="#* | node()">
<xsl:copy>
<xsl:apply-templates select="#* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<xsl:copy>
<xsl:sequence select="mf:group(*, 1)"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
With Saxon for the input
<root>
<root1>1234</root1>
<root2>5678</root2>
<level1>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
</level1>
<level2>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
</level2>
<level3>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
</level3>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level21>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</level21>
<level2>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
</level2>
<level3>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
</level3>
<level4>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</level4>
<level4>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level21>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</level21>
</root>
I get the result
<root>
<root1>1234</root1>
<root2>5678</root2>
<level1>
<a>line 1</a>
<b>line 2</b>
<c>line 3</c>
<level2>
<d>line 4</d>
<e>line 5</e>
<f>line 6</f>
<g>line 7</g>
<level3>
<SequenceCount>1</SequenceCount>
<h>line 8</h>
<i>line 9</i>
<j>line 10</j>
<k>line 11</k>
<l>line 12</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level21>
<SequenceCount>2</SequenceCount>
<d>line 214</d>
<e>line 215</e>
<f>line 216</f>
<g>line 217</g>
</level21>
<level2>
<d>line 19</d>
<e>line 20</e>
<f>line 21</f>
<g>line 22</g>
<level3>
<SequenceCount>3</SequenceCount>
<h>line 23</h>
<i>line 24</i>
<j>line 25</j>
<k>line 26</k>
<l>line 27</l>
<level4>
<SequenceCount>1</SequenceCount>
<m>line 28</m>
<n>line 29</n>
<o>line 30</o>
</level4>
<level4>
<SequenceCount>2</SequenceCount>
<m>line 13</m>
<n>line 14</n>
<o>line 15</o>
</level4>
</level3>
</level2>
<level21>
<SequenceCount>4</SequenceCount>
<d>line 224</d>
<e>line 225</e>
<f>line 226</f>
<g>line 227</g>
</level21>
</level1>
</root>

wso2 cache mediator response in binary (it should be XML)

I'm learning about wso2 ESB 4.6.0. I'm studying right now about mediators. I implemented cache mediator as below.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="cacheProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<cache id="myCache" scope="per-mediator" collector="false" hashGenerator="org.wso2.caching.digest.DOMHASHGenerator" timeout="3" maxMessageSize="1000">
<implementation type="memory" maxSize="1000"/>
</cache>
<send>
<endpoint>
<address uri="http://localhost:44444/ws/MediatorsWS"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<cache id="myCache" scope="per-mediator" collector="true"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:44444/ws/MediatorsWS"/>
</endpoint>
</target>
<publishWSDL uri="http://localhost:44444/ws/MediatorsWS?wsdl"/>
<description></description>
</proxy>
It redirects to a webservice implemented with JAX-WS receiving SOAP 1.1. Here is the wsdl:
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:tns="http://clone.ws.wso2lessons/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://clone.ws.wso2lessons/">
<wsdl:types>
<xsd:schema attributeFormDefault="unqualified" elementFormDefault="unqualified">
<xsd:import namespace="http://clone.ws.wso2lessons/" schemaLocation="cacheProxy?xsd=http://localhost:44444/ws/MediatorsWS?xsd=1.xsd"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="receiveMessage">
<wsdl:part name="parameters" element="tns:receiveMessage"/>
</wsdl:message>
<wsdl:message name="receiveMessageResponse">
<wsdl:part name="parameters" element="tns:receiveMessageResponse"/>
</wsdl:message>
<wsdl:message name="replyMessage">
<wsdl:part name="parameters" element="tns:replyMessage"/>
</wsdl:message>
<wsdl:message name="replyMessageResponse">
<wsdl:part name="parameters" element="tns:replyMessageResponse"/>
</wsdl:message>
<wsdl:portType name="cacheProxyPortType">
<wsdl:operation name="receiveMessage">
<wsdl:input message="tns:receiveMessage" wsaw:Action="http://clone.ws.wso2lessons/MediatorsWS/receiveMessageRequest"/>
<wsdl:output message="tns:receiveMessageResponse" wsaw:Action="http://clone.ws.wso2lessons/MediatorsWS/receiveMessageResponse"/>
</wsdl:operation>
<wsdl:operation name="replyMessage">
<wsdl:input message="tns:replyMessage" wsaw:Action="http://clone.ws.wso2lessons/MediatorsWS/replyMessageRequest"/>
<wsdl:output message="tns:replyMessageResponse" wsaw:Action="http://clone.ws.wso2lessons/MediatorsWS/replyMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="cacheProxySoap11Binding" type="tns:cacheProxyPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="receiveMessage">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="replyMessage">
<soap:operation soapAction="" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="cacheProxySoap12Binding" type="tns:cacheProxyPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="receiveMessage">
<soap12:operation soapAction="" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="replyMessage">
<soap12:operation soapAction="" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="cacheProxyHttpBinding" type="tns:cacheProxyPortType">
<http:binding verb="POST"/>
<wsdl:operation name="receiveMessage">
<http:operation location="receiveMessage"/>
<wsdl:input>
<mime:content type="text/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="replyMessage">
<http:operation location="replyMessage"/>
<wsdl:input>
<mime:content type="text/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="cacheProxy">
<wsdl:port name="cacheProxyHttpSoap11Endpoint" binding="tns:cacheProxySoap11Binding">
<soap:address location="http://PCPPTCERTDEV01:8280/services/cacheProxy.cacheProxyHttpSoap11Endpoint"/>
</wsdl:port>
<wsdl:port name="cacheProxyHttpsSoap11Endpoint" binding="tns:cacheProxySoap11Binding">
<soap:address location="https://PCPPTCERTDEV01:8243/services/cacheProxy.cacheProxyHttpsSoap11Endpoint"/>
</wsdl:port>
<wsdl:port name="cacheProxyHttpsSoap12Endpoint" binding="tns:cacheProxySoap12Binding">
<soap12:address location="https://PCPPTCERTDEV01:8243/services/cacheProxy.cacheProxyHttpsSoap12Endpoint"/>
</wsdl:port>
<wsdl:port name="cacheProxyHttpSoap12Endpoint" binding="tns:cacheProxySoap12Binding">
<soap12:address location="http://PCPPTCERTDEV01:8280/services/cacheProxy.cacheProxyHttpSoap12Endpoint"/>
</wsdl:port>
<wsdl:port name="cacheProxyHttpsEndpoint" binding="tns:cacheProxyHttpBinding">
<http:address location="https://PCPPTCERTDEV01:8243/services/cacheProxy.cacheProxyHttpsEndpoint"/>
</wsdl:port>
<wsdl:port name="cacheProxyHttpEndpoint" binding="tns:cacheProxyHttpBinding">
<http:address location="http://PCPPTCERTDEV01:8280/services/cacheProxy.cacheProxyHttpEndpoint"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
When I send a message to operation replyMessage, the response message is cached succesfully (there is a System.out.println() on the java method, which is not called at the cache timeframe). However, the returned message I get is this:
<axis2ns27:binary xmlns:axis2ns27="http://ws.apache.org/commons/ns/payload">PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxTOkVudmVsb3BlIHhtbG5zOlM9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3NvYXAvZW52ZWxvcGUvIj48UzpCb2R5PjxuczI6cmVwbHlNZXNzYWdlUmVzcG9uc2UgeG1sbnM6bnMyPSJodHRwOi8vY2xvbmUud3Mud3NvMmxlc3NvbnMvIj48cmV0dXJuPmhlbGxvIHRoZXJlIHJlc3BvbmRpZGEuPC9yZXR1cm4+PC9uczI6cmVwbHlNZXNzYWdlUmVzcG9uc2U+PC9TOkJvZHk+PC9TOkVudmVsb3BlPg==</axis2ns27:binary>
If I don't use this mediator, message is returned correctly. What am I missing here?
we use passthrough transport, it doesnt build the message..Can you switch back to NIO transport and check?

Geoserver SLD styling issue with external graphics and attribute rules

I am creating a SLD for Geoserver wms layer. The SLD validates without error but the icons will not show in the map. I am using attribute based rules to compare strings to have the correct image show for the correct feature. Here is my code and thanks for any help!
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Upper Shore Image Points</Name>
<UserStyle>
<Title>Vendor Points</Title>
<FeatureTypeStyle>
<Rule>
<Name>Famers Market</Name>
<Title>All Farmers Markets</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>farmers maket vendor</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Farmers Markets.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Fruit and Vegetable</Name>
<Title>All Fruit and Vegetable</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Fruit and Vegetable Farm</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Fruit and Vegetable Farms.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Horse Stable</Name>
<Title>All Horse Stables</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Horse Stable</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Horse Stable.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Wool Products</Name>
<Title>All Wool Products</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Wool Products</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Wool Products.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Restaurant</Name>
<Title>All Restaurants</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Restaurant</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Restaurant.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Coffee Roasting</Name>
<Title>All Coffee Roasting</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Coffee Roasting</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Coffee Roasting.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Charter Service</Name>
<Title>All Charter Services</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Charter Service</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Charter Service.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Apiary</Name>
<Title>All Apiaries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Apiary</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Apiary.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Vineyard</Name>
<Title>All Vineyards</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Vineyard</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Vineyard.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Retail Seafood</Name>
<Title>All Retail Seafood</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Retail Seafood</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Retail Seafood.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Bakery</Name>
<Title>All Bakeries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Bakery</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Bakery.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Dairy/Eggs</Name>
<Title>All Dairy/ Eggs</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Dairy/Eggs</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Dairy_Eggs.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Christmas Tree Farm</Name>
<Title>All Christmas Tree Farms</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Christmas Tree Farm</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Christmas Tree Farm.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Grains</Name>
<Title>All Grain Farms</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Grains</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Grains.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Meat Products</Name>
<Title>All Meat Products</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Meat Products</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Meat.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Nursery</Name>
<Title>All Nurseries</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Nursery</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Nursery.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>Petting Zoo</Name>
<Title>All Petting Zoos</Title>
<ogc:Filter>
<ogc:PropertyIsLike wildCard="*" singleChar="." escape="!">
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>Petting Zoo</ogc:Literal>
</ogc:PropertyIsLike>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<ExternalGraphic>
<OnlineResource
xlink:type="simple"
xlink:href="Petting Zoo.jpg" />
<Format>image/jpeg</Format>
</ExternalGraphic>
<Size>32</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
I realize this post is old but maybe someone will benefit from my answer.
I didn't succeed in using relative image paths so I turned to using URL paths.
Put image(s) in $GEOSERVER_DATA_DIR/styles and reference it with http://localhost:8081/geoserver/styles/some_image.png
For example
<ExternalGraphic>
<OnlineResource xlink:type="simple" xlink:href="http://localhost:8081/geoserver/styles/some_image.png"/>
<Format>image/png</Format>
</ExternalGraphic>
Nice answer, but you need to change the 8081 to 8080 assuming the geoserver instance is working on port 8080
you can put your image in style folder

Resources