Incomplete display of style in geoserver generated in QGIS - geoserver
SLD generated in QGIS 2.10 PISA is as follows-
<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<se:Name>state1</se:Name>
<UserStyle>
<se:Name>state1</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name>ADJACENT COUNTRIES</se:Name>
<se:Description>
<se:Title>ADJACENT COUNTRIES</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal>ADJACENT COUNTRIES</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#d640d1</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>ANDAMAN & NICOBAR</se:Name>
<se:Description>
<se:Title>ANDAMAN & NICOBAR</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal>ANDAMAN & NICOBAR</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#62eadf</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>ANDHRA PRADESH</se:Name>
<se:Description>
<se:Title>ANDHRA PRADESH</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal>ANDHRA PRADESH</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#869edf</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>ARUNACHAL PRADESH</se:Name>
<se:Description>
<se:Title>ARUNACHAL PRADESH</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal>ARUNACHAL PRADESH</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#85e6ee</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Rule>
<se:Name>ASSAM</se:Name>
<se:Description>
<se:Title>ASSAM</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal>ASSAM</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#aede72</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
<se:Name></se:Name>
<se:Description>
<se:Title>STATE is ''</se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>STATE</ogc:PropertyName>
<ogc:Literal></ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<se:PolygonSymbolizer>
<se:Fill>
<se:SvgParameter name="fill">#ebcf60</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
<se:SvgParameter name="stroke-width">0.26</se:SvgParameter>
<se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
</se:Stroke>
</se:PolygonSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
The above SLD when added as a style to one of the layers in GeoServer 2.7.2 and published as a wms, is not able to display the labels(state names). In SLD, only the states are categorized and names have been given to them.
Can someone please help me on this.
The SLD does not contain any TextSymbolizer, so there is no way it can display labels. If you have labels configured, you should report the lack of a TextSymbolizer as a bug in QGis
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
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>
xsl:for-each-group positional grouping flat xml to hierarchical
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>
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