Created
June 4, 2016 19:34
-
-
Save techzilla/378dcade689343561d9a63a845cc2f73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
## | |
## FILE: split-vss2xhtml.sh | |
## | |
## DESCRIPTION: Split VSS/SVG Sections | |
## | |
## Exit Point | |
die() { | |
[ -n "$2" ] && echo "$2" | |
exit $1 | |
} | |
USAGE="Usage: $0 [FILE]" | |
[ -z "$1" ] && die 64 "$USAGE" | |
XML_SRC="$1" | |
XML_XSL="${0%%.sh}.xsl" | |
[ -d "tmp" ] && rm -rf "tmp" | |
mkdir "tmp" | |
sed -i '/^Fridrich A _XFTRIGGER(EventXFMod)/d' "$XML_SRC" | |
#| xmllint --huge --format --noblanks --dropdtd --nsclean > "${XML_SRC}.$$" - | |
#mv "${XML_SRC}.$$" "$XML_SRC" | |
saxonb-xslt -ext:on -s "${XML_SRC}" -xsl "${XML_XSL}" | |
die 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<xsl:stylesheet | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:svg="http://www.w3.org/2000/svg" | |
version="2.0"> | |
<xsl:strip-space elements="*"/> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- Select any subtree with a "Person" element as the root --> | |
<xsl:template match="/html/body"> | |
<xsl:apply-templates select="descendant::svg:svg" /> | |
</xsl:template> | |
<!-- Copy everything that has been selected --> | |
<xsl:template match="svg:svg"> | |
<xsl:variable name="number"> | |
<xsl:number/> | |
</xsl:variable> | |
<xsl:result-document href="tmp/{$number}.svg"> | |
<svg height="{@height}" width="{@width}" xmlns="http://www.w3.org/1999/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg"> | |
<xsl:copy-of select="node()"/> | |
</svg> | |
</xsl:result-document> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment