This file contains hidden or 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
exclude-result-prefixes="msxsl exsl other" |
This file contains hidden or 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 version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" | |
exclude-result-prefixes="msxsl"> |
This file contains hidden or 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
# msxml_xslt.py | |
import sys, os | |
def main(argv): | |
if len(argv) < 3: | |
print("Usage: python msxml_xslt.py <input.xml> <stylesheet.xsl> [output.xml]", file=sys.stderr) | |
sys.exit(2) | |
in_arg, xsl_arg = argv[1], argv[2] | |
out_arg = argv[3] if len(argv) >= 4 else "output.xml" |
This file contains hidden or 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 version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:msxsl" | |
exclude-result-prefixes="msxsl"> | |
<!-- Example of turning an RTF into nodes --> | |
<xsl:variable name="frag"> | |
<items><item a="1"/><item a="2"/></items> | |
</xsl:variable> | |
This file contains hidden or 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
import win32com.client as win32 | |
# Load XML | |
xml = win32.Dispatch("Msxml2.DOMDocument.6.0") | |
xml.async = False | |
xml.resolveExternals = False | |
xml.validateOnParse = False | |
if not xml.load(r"input.xml"): | |
raise RuntimeError(xml.parseError.reason) | |
This file contains hidden or 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
txt = open("style_msxsl.xsl","r",encoding="utf-8").read() | |
txt = txt.replace("msxsl:node-set(", "exsl:node-set(") | |
if 'xmlns:exsl="http://exslt.org/common"' not in txt: | |
txt = txt.replace('<xsl:stylesheet', | |
'<xsl:stylesheet xmlns:exsl="http://exslt.org/common"') | |
xslt = etree.XSLT(etree.XML(txt.encode("utf-8"))) |
This file contains hidden or 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:template match="/"> | |
<!-- collect once, reuse --> | |
<xsl:variable name="nodes" select="//Constituents/Constituent"/> | |
<xsl:if test="$nodes"> | |
<Root> | |
<!-- either iterate... --> | |
<xsl:for-each select="$nodes"> | |
<!-- do your per-Constituent work here, or call a template --> | |
<xsl:call-template name="emit-constituent"/> | |
</xsl:for-each> |
This file contains hidden or 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:if test="Constituents/Constituent"> | |
<!-- exists under the current node --> | |
</xsl:if> |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" | |
exclude-result-prefixes="msxsl"> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- ======================= | |
1) Data tables in vars |
This file contains hidden or 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
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" | |
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
xmlns:msxsl="urn:schemas-microsoft-com:xslt" | |
exclude-result-prefixes="msxsl"> | |
<xsl:output method="xml" indent="yes"/> | |
<!-- ======================= | |
1) Data tables in vars |
NewerOlder