Ace
Ace

Reputation: 867

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 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 -->

Upvotes: 1

Views: 855

Answers (2)

Andrew Skirrow
Andrew Skirrow

Reputation: 3451

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>

Upvotes: 2

time4tea
time4tea

Reputation: 2197

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

Upvotes: 0

Related Questions