开发者

XSLT: Adding a processing instruction at the end of the file

I have a <?hard-pagebreak?> PI at the end of a whole bunch of .xml files (ie. on a new line after the last node? Whats the best way开发者_如何学Python for a XSLT to do that?

Example input:

<?xml version="1.0" encoding="UTF-8"?>
<section version="5"
         xml:id="summary"
         xreflabel="Issues Summary"
         xmlns="http://docbook.org/ns/docbook">
...stuff
</section>
<!-- need page break here -->


Is this what your looking for?

<xsl:template match="/">
  <RootNode> 
  </RootNode>
  <xsl:processing-instruction name="hard-pagebreak" />
</xsl:template>

update The below is an improved version of above that also copies the source XML document

<xsl:template match="/">
  <xsl:apply-templates/>
  <xsl:processing-instruction name="hard-pagebreak" />
</xsl:template>

<xsl:template match="node() | @*">
  <xsl:copy>
     <xsl:apply-templates select="node() | @*" />
  </xsl:copy>
</xsl:template>


Are you looking for this: http://www.w3schools.com/XSL/el_processing-instruction.asp

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜