-
-
Save dth/288359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 :( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try this: | |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
<xsl:output method="xml" /> | |
<xsl:template match="/applications"> | |
<xsl:apply-templates/> | |
</xsl:template> | |
<xsl:template match="application"> | |
<div>flibble</div> | |
</xsl:template> | |
<xsl:template match="*"/> | |
</xsl:stylesheet> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment