Skip to content

Instantly share code, notes, and snippets.

@sprklinginfo
Forked from petermacdonald/splitXMLFile.xsl
Last active August 29, 2015 14:14
Show Gist options
  • Save sprklinginfo/6bb882ae19fccb1305a5 to your computer and use it in GitHub Desktop.
Save sprklinginfo/6bb882ae19fccb1305a5 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:default="http://www.loc.gov/mods/v3"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon">
<!--
This stylesheet was originally designed to split an XML file containing multiple MODS records into separate MODS files.
It names each file by targeting the identifier element in the record being exported to use as the file name.
Requires the SAXON Extensions be loaded:
http://users.breathe.com/mhkay/saxon/saxon5-5-1/extensions.html
-->
<!-- INSTRUCTIONS
1. Load your XML file into oXygen:
2. load splitXMLFile.xsl into oXygen and select Saxon6.5.5 as the processor.
5. Run splitXMLFile.xsl on the MODS XML file (if necessary, delete the name "mods.xml" from oXygen's Output: box).
-->
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- Remove all CRs, line feeds, etc. -->
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:for-each select="/*/*/*[not(. > 3)]">
<saxon:output href="Y:\xslt\scripts-output\{./default:identifier}.xml">
<xsl:copy-of select="."/>
</saxon:output>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment