Make XSLT and XML Output to a XML File -
i have few problems xslt.
i have xml file:
<?xml version="1.0" encoding="utf-8" ?> <?xml-stylesheet type="text/xsl" href="xsltest.xsl"?> <pages> <page> <title>new title</title> <id>4782</id> <timestamp>2012-09-13 13:15:33</timestamp> <contributor> <username>kf</username> <id>2</id> </contributor> <text xml:space="preserve"> text </text> </page> </pages>
and xsl file:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:template match="/"> <xsl:for-each select="pages/page"> <content> <id><xsl:value-of select="id"/></id> <title><xsl:value-of select="title"/></title> <created><xsl:value-of select="timestamp"/></created> <created_by><xsl:value-of select="contributor/username"/></created_by> </content> </xsl:for-each> </xsl:template>
so problems:
the xml file transformation partially work. values want except title.
i save transformed code new xml file.
the iteration necessary because original file want change bigger more <pages>
.
the xml file transformation partially work. values want except title. (...) have no idea why doesn't work on webeditor of w3
never trust content on w3schools - in no way related w3c, , tools cannot expected compliant specifications. recommend never use site again test xslt transformations. @ time of writing, http://xsltransform.net great alternative can relied upon.
i save transformed code new xml file.
looking @ stylesheet reference in xml document:
<?xml-stylesheet type="text/xsl" href="xsltest.xsl"?>
it looks doing transformation in browser. major browsers include xslt 1.0 processor, not allow save transformation result file. in browsers, transformations meant facilitate display of data, not make permanent changes document.
to save output file, need to
- use command line tool saxon
- use xslt library , programming language of choice parse input file, transform , output result file
one last comment on xslt versions:
your stylesheet states code should use xslt version 2.0:
<xsl:stylesheet version="2.0">
but currently, no browser supports xslt 2.0. use features specific xslt 2.0 (you don't use any), need xslt 2.0 processor.
Comments
Post a Comment