Please anyone help me on creating a new output file using xsl:document.
I found the following example from book "XSLT 2nd Edition Programmer's Reference"
poem.xml
========
<poem>
<author>Rupert Brooke</author>
<date>1912</date>
<title>Song</title>
<stanza>
<line>And suddenly the wind comes soft,</line>
<line>And Spring is here again;</line>
<line>And the hawthorn quickens with buds of green</line>
<line>And my heart with buds of pain.</line>
</stanza>
<stanza>
<line>My heart all Winter lay so numb,</line>
<line>The earth so dead and frore,</line>
<line>That I never thought the Spring would come again</line>
<line>Or my heart wake any more.</line>
</stanza>
<stanza>
<line>But Winter's broken and earth has woken,</line>
<line>And the small birds cry again;</line>
<line>And the hawthorn hedge puts forth its buds,</line>
<line>And my heart puts forth its pain.</line>
</stanza>
</poem>
split.xsl
=========
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.1">
<xsl:template match="poem">
<poem>
<xsl:copy-of select="title"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="date"/>
<xsl:apply-templates select="stanza"/>
</poem>
</xsl:template>
<xsl:template match="stanza">
<xsl:variable name="file" select="concat('verse', position(), '.xml')"/>
<verse number="{position()}" href="{$file}"/>
<xsl:document href="{$file}">
<xsl:copy-of select="."/>
</xsl:document>
</xsl:template>
</xsl:stylesheet>
How and where are the following output files generated?
one principal output file:
<?xml version="1.0" encoding="utf-8" ?>
<poem>
<title>Song</title>
<author>Rupert Brooke</author>
<date>1912</date>
<verser number="1" href="versel1.xml"/>
<verser number="2" href="versel2.xml"/>
<verser number="3" href="versel3.xml"/>
</poem>
three further output files:
<?xml version="1.0" encoding="utf-8" ?>
<stanza>
<line>And suddenly the wind comes soft, </line>
<line>and spring is here again;</line>
<line>and the hawthorn quickens with buds of green</line>
<line>and my heart with buds of pain.</line>
</stanza>
Thanks in advance,
chrislx
I found the following example from book "XSLT 2nd Edition Programmer's Reference"
poem.xml
========
<poem>
<author>Rupert Brooke</author>
<date>1912</date>
<title>Song</title>
<stanza>
<line>And suddenly the wind comes soft,</line>
<line>And Spring is here again;</line>
<line>And the hawthorn quickens with buds of green</line>
<line>And my heart with buds of pain.</line>
</stanza>
<stanza>
<line>My heart all Winter lay so numb,</line>
<line>The earth so dead and frore,</line>
<line>That I never thought the Spring would come again</line>
<line>Or my heart wake any more.</line>
</stanza>
<stanza>
<line>But Winter's broken and earth has woken,</line>
<line>And the small birds cry again;</line>
<line>And the hawthorn hedge puts forth its buds,</line>
<line>And my heart puts forth its pain.</line>
</stanza>
</poem>
split.xsl
=========
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl=" version="1.1">
<xsl:template match="poem">
<poem>
<xsl:copy-of select="title"/>
<xsl:copy-of select="author"/>
<xsl:copy-of select="date"/>
<xsl:apply-templates select="stanza"/>
</poem>
</xsl:template>
<xsl:template match="stanza">
<xsl:variable name="file" select="concat('verse', position(), '.xml')"/>
<verse number="{position()}" href="{$file}"/>
<xsl:document href="{$file}">
<xsl:copy-of select="."/>
</xsl:document>
</xsl:template>
</xsl:stylesheet>
How and where are the following output files generated?
one principal output file:
<?xml version="1.0" encoding="utf-8" ?>
<poem>
<title>Song</title>
<author>Rupert Brooke</author>
<date>1912</date>
<verser number="1" href="versel1.xml"/>
<verser number="2" href="versel2.xml"/>
<verser number="3" href="versel3.xml"/>
</poem>
three further output files:
<?xml version="1.0" encoding="utf-8" ?>
<stanza>
<line>And suddenly the wind comes soft, </line>
<line>and spring is here again;</line>
<line>and the hawthorn quickens with buds of green</line>
<line>and my heart with buds of pain.</line>
</stanza>
Thanks in advance,
chrislx