Skip to content

Instantly share code, notes, and snippets.

@harukizaemon
Created January 28, 2010 01:13
Show Gist options
  • Save harukizaemon/288336 to your computer and use it in GitHub Desktop.
Save harukizaemon/288336 to your computer and use it in GitHub Desktop.
Given this XSLT
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="xml" />
<xsl:template match="/applications/application">
<div>flibble</div>
</xsl:template>
</xsl:stylesheet>
and this XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE applications>
<applications>
<application></application>
<other-url-tag>1</other-url-tag>
<other-url-tag1>2</other-url-tag1>
<other-url-tag2>3</other-url-tag2>
</applications>
I'm getting:
<?xml version="1.0"?>
<div>flibble</div>
1
2
3
When I expected to get:
<?xml version="1.0"?>
<div>flibble</div>
I've tried various combinations of things that _do_ work and make perfect sense, eg:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="xml" />
<xsl:template match="/">
<xsl:apply-templates select="/applications/application" />
</xsl:template>
<xsl:template match="/applications/application">
<div>flibble</div>
</xsl:template>
</xsl:stylesheet>
but I'm stumped as to the original behaviour. At the very least, I'd expect to get:
<?xml version="1.0"?>
<div>flibble</div>
<other-url-tag>1</other-url-tag>
<other-url-tag1>2</other-url-tag1>
<other-url-tag2>3</other-url-tag2>
Next attempt:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="xml" />
<xsl:template match="/applications/application">
<div>flibble</div>
</xsl:template>
<xsl:template match="*"></xsl:template>
</xsl:stylesheet>
Produces no output :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment