Skip to content

Instantly share code, notes, and snippets.

@pgundlach
Created March 22, 2018 12:11
Show Gist options
  • Save pgundlach/17370fa95dba89e1976b9e8a9b72cd5a to your computer and use it in GitHub Desktop.
Save pgundlach/17370fa95dba89e1976b9e8a9b72cd5a to your computer and use it in GitHub Desktop.
Simple RELAX NG to adoc transformation
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
version="2.0">
<xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
<xsl:variable name="startxml"><xsl:text>
[source, xml]
-------------------------------------------------------------------------------
</xsl:text></xsl:variable>
<xsl:variable name="endxml"><xsl:text>
-------------------------------------------------------------------------------
</xsl:text></xsl:variable>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<xsl:value-of select="$startxml"/>
<xsl:apply-templates/>
<xsl:value-of select="$endxml"/>
</xsl:template>
<xsl:template match="a:documentation">
<xsl:value-of select="$endxml"/>
<xsl:value-of select="."/>
<xsl:value-of select="$startxml"/>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment