XSL problem

W3c's SVG logo
Image via Wikipedia

A while back I wrote some XSL to manipulate the SVG files my Groovy programs were outputting.

Now either I did something fancy back then that I have forgotten or else some piece of code has broken in the last couple of months (or maybe become less tolerant of my bad XML?) – because it doesn’t work now.

The XSL reads:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" indent="yes"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="colour">yellow</xsl:param>
<xsl:template match="/">
	<xsl:apply-templates select="svg"/>
</xsl:template>
<xsl:template match="svg">
	<xsl:copy>
		<xsl:for-each select="@*">
			<xsl:copy/>
		</xsl:for-each>
		<xsl:text>
</xsl:text>
		<xsl:apply-templates select="rect"/>
		<xsl:apply-templates select="line"/>
		<xsl:apply-templates select="text"/>
		<xsl:apply-templates select="circle"/>
	</xsl:copy>
</xsl:template>
<xsl:template match="line">
	<xsl:copy>
		<xsl:for-each select="@*">
			<xsl:copy/>
		</xsl:for-each>
	</xsl:copy>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="rect">
	<xsl:copy>
		<xsl:for-each select="@*">
			<xsl:copy/>
		</xsl:for-each>
	</xsl:copy>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="text">
	<xsl:copy>
		<xsl:for-each select="@*|node()">
			<xsl:copy/>
		</xsl:for-each>
	</xsl:copy>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="circle">
	<xsl:if test="@stroke=$colour">
		<xsl:copy>
			<xsl:for-each select="@*">
				<xsl:copy/>
			</xsl:for-each>
		</xsl:copy>
		<xsl:text>
</xsl:text>
	</xsl:if>
</xsl:template>
</xsl:stylesheet>

While the SVG (rather a small fraction of it) reads:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1000px" height="800px" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x='0' y='0' width='1000' height='800' fill='white' />
<text x='100' y='800' style='font-family: Helvetica; font-size: 10; fill: black'>Page size: 4096: 0 to 2% memory</text>
<line x1='90' y1='705' x2='905' y2='705' stroke='black' stroke-width='10' />
<line x1='95' y1='705' x2='95' y2='100' stroke='black' stroke-width='10' />
<line x1='100' y1='715' x2='100' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='95' y='720' style='font-family: Helvetica; font-size:10; fill: maroon'>0</text>
<line x1='80' y1='100' x2='900' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='30' y='105' style='font-family: Helvetica; font-size:10; fill: maroon'>7bb0</text>
<line x1='300' y1='715' x2='300' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='295' y='720' style='font-family: Helvetica; font-size:10; fill: maroon'>75341312</text>
<line x1='80' y1='250' x2='900' y2='250' stroke='lightgrey' stroke-width='1' />
<text x='30' y='255' style='font-family: Helvetica; font-size:10; fill: maroon'>6cc4</text>
<line x1='500' y1='715' x2='500' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='495' y='720' style='font-family: Helvetica; font-size:10; fill: maroon'>150682624</text>
<line x1='80' y1='400' x2='900' y2='400' stroke='lightgrey' stroke-width='1' />
<text x='30' y='405' style='font-family: Helvetica; font-size:10; fill: maroon'>5dd8</text>
<line x1='700' y1='715' x2='700' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='695' y='720' style='font-family: Helvetica; font-size:10; fill: maroon'>226023936</text>
<line x1='80' y1='550' x2='900' y2='550' stroke='lightgrey' stroke-width='1' />
<text x='30' y='555' style='font-family: Helvetica; font-size:10; fill: maroon'>4eec</text>
<line x1='900' y1='715' x2='900' y2='100' stroke='lightgrey' stroke-width='1' />
<text x='895' y='720' style='font-family: Helvetica; font-size:10; fill: maroon'>301365249</text>
<line x1='80' y1='700' x2='900' y2='700' stroke='lightgrey' stroke-width='1' />
<text x='30' y='705' style='font-family: Helvetica; font-size:10; fill: maroon'>4000</text>
<text x='25' y='300' transform='rotate(90, 25, 300)' style='font-family: Helvetica; font-size:10; fill:red'>PAGES</text>
<text x='100' y='750.0' style='font-family:Helvetica; font-size:10; fill:red'>INSTRUCTIONS (376706 per pixel)</text>
<text x='800' y='90' style='font-family:Helvetica; font-size:10; fill: black'>html</text>
<rect x='910' y='120' width='5' height='5' fill='red' stroke='black' stroke-width='1' />
<text x='920' y='125' style='font-family:Helvetica; font-size:10; fill:black'>Instructions</text>
<rect x='910' y='150' width='5' height='5' fill='green' stroke='black' stroke-width='1' />
<text x='920' y='155' style='font-family:Helvetica; font-size:10; fill:black'>Modify</text>
<rect x='910' y='180' width='5' height='5' fill='blue' stroke='black' stroke-width='1' />
<text x='920' y='185' style='font-family:Helvetica; font-size:10; fill:black'>Load</text>
<rect x='910' y='210' width='5' height='5' fill='yellow' stroke='black' stroke-width='1' />
<text x='920' y='215' style='font-family:Helvetica; font-size:10; fill:black'>Store</text>
<circle cx='100' cy='700' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='100' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='101' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='102' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='103' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='104' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='105' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='106' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='107' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='108' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='109' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='110' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='111' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='112' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='700' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='698' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='697' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='676' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='683' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='678' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='674' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='675' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='679' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='680' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='682' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='685' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='684' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='687' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='686' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='694' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='689' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='690' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='692' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='693' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='677' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='113' cy='681' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='700' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='698' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='697' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='679' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='674' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='660' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='659' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='689' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='694' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='680' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='683' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='681' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='682' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='114' cy='676' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='115' cy='698' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='115' cy='697' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='115' cy='699' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='115' cy='700' r='1' fill='none' stroke='red' stroke-width='1' />
<circle cx='106' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='107' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='107' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='108' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='108' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='109' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='109' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='110' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='110' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='111' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='111' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='112' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='112' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='112' cy='671' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='112' cy='698' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='698' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='671' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='687' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='659' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='113' cy='658' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='114' cy='671' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='114' cy='659' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='114' cy='658' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='114' cy='698' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='114' cy='697' r='1' fill='none' stroke='yellow' stroke-width='1' />
<circle cx='894' cy='658' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='894' cy='698' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='895' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='895' cy='671' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='895' cy='653' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='895' cy='658' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='896' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='896' cy='671' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='897' cy='671' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='897' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='897' cy='653' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='897' cy='656' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='898' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='898' cy='671' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='899' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='899' cy='671' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='899' cy='653' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='899' cy='656' r='1' fill='none' stroke='green' stroke-width='1' />
<circle cx='900' cy='657' r='1' fill='none' stroke='green' stroke-width='1' />
</svg>

But using xsltproc generates an empty output…

Advertisement

2 responses to “XSL problem”

  1. […] cartesian product Stuff about computing Skip to content HomeAbout ← XSL problem […]

  2. […] XSL problem (cartesianproduct.wordpress.com) […]

%d bloggers like this: