diff options
author | Benjamin Franzke <bfr@qbus.de> | 2015-02-18 15:48:18 +0100 |
---|---|---|
committer | Benjamin Franzke <bfr@qbus.de> | 2015-02-18 15:54:24 +0100 |
commit | aceed71c01b9a25ee4fc70074d3edbd7c95042ad (patch) | |
tree | 04c1409cfc7449a03b37e47559acd5c3baf52c44 /util.xsl | |
download | endnote-import-aceed71c01b9a25ee4fc70074d3edbd7c95042ad.tar.gz endnote-import-aceed71c01b9a25ee4fc70074d3edbd7c95042ad.tar.bz2 endnote-import-aceed71c01b9a25ee4fc70074d3edbd7c95042ad.zip |
Implement simple xml import using xsl and load xml
Diffstat (limited to 'util.xsl')
-rw-r--r-- | util.xsl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/util.xsl b/util.xsl new file mode 100644 index 0000000..19e6cf9 --- /dev/null +++ b/util.xsl @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + + <xsl:template match="*" mode="copy-cdata"> + <cdata> + <xsl:apply-templates /> + </cdata> + </xsl:template> + + <xsl:template match="*" mode="copy-html"> + <xsl:apply-templates select="*|text()" mode="verb" /> + </xsl:template> + + <!-- + Copy nodeset as escaped XML + http://logit.yudichev.net/2007/11/xslt-output-xml-escaped-copy-of-source.html + --> + <xsl:template match="*|@*" mode="verb"> + <xsl:variable name="node-type"> + <xsl:call-template name="node-type"/> + </xsl:variable> + <xsl:choose> + <xsl:when test="$node-type='element'"> <!-- element --> + <xsl:text><</xsl:text> + <xsl:value-of select="name()"/> + <xsl:apply-templates select="@*" mode="verb"/> + <xsl:text>></xsl:text> + <xsl:apply-templates mode="verb"/> + <xsl:text></</xsl:text> + <xsl:value-of select="name()"/> + <xsl:text>></xsl:text> + </xsl:when> + <xsl:when test="$node-type='text'"> <!-- text --> + <xsl:value-of select="self::text()"/> + </xsl:when> + <xsl:when test="$node-type='attribute'"> <!--any attribute--> + <xsl:text> </xsl:text> + <xsl:value-of select="name()"/> + <xsl:text>="</xsl:text> + <xsl:value-of select="."/> + <xsl:text>"</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:template> + <xsl:template name="node-type"> + <xsl:param name="node" select="."/> + <xsl:apply-templates mode="nodetype" select="$node"/> + </xsl:template> + <xsl:template mode="nodetype" match="*">element</xsl:template> + <xsl:template mode="nodetype" match="@*">attribute</xsl:template> + <xsl:template mode="nodetype" match="text()">text</xsl:template> + +</xsl:stylesheet> |