Mercurial > repos > shellac > sam_consensus_v3
comparison env/lib/python3.9/site-packages/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author | shellac |
---|---|
date | Mon, 22 Mar 2021 18:12:50 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4f3585e2f14b |
---|---|
1 <?xml version="1.0" encoding="UTF-8"?> | |
2 <!-- | |
3 based on an original transform by Eddie Robertsson | |
4 2001/04/21 fn: added support for included schemas | |
5 2001/06/27 er: changed XMl Schema prefix from xsd: to xs: and changed to the Rec namespace | |
6 2009/12/10 hj: changed Schematron namespace to ISO URI (Holger Joukl) | |
7 --> | |
8 <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | |
9 xmlns:sch="http://purl.oclc.org/dsdl/schematron" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
10 <!-- Set the output to be XML with an XML declaration and use indentation --> | |
11 <xsl:output method="xml" omit-xml-declaration="no" indent="yes" standalone="yes"/> | |
12 <!-- --> | |
13 <!-- match schema and call recursive template to extract included schemas --> | |
14 <!-- --> | |
15 <xsl:template match="xs:schema"> | |
16 <!-- call the schema definition template ... --> | |
17 <xsl:call-template name="gatherSchema"> | |
18 <!-- ... with current current root as the $schemas parameter ... --> | |
19 <xsl:with-param name="schemas" select="/"/> | |
20 <!-- ... and any includes in the $include parameter --> | |
21 <xsl:with-param name="includes" | |
22 select="document(/xs:schema/xs:*[self::xs:include or self::xs:import or self::xs:redefine]/@schemaLocation)"/> | |
23 </xsl:call-template> | |
24 </xsl:template> | |
25 <!-- --> | |
26 <!-- gather all included schemas into a single parameter variable --> | |
27 <!-- --> | |
28 <xsl:template name="gatherSchema"> | |
29 <xsl:param name="schemas"/> | |
30 <xsl:param name="includes"/> | |
31 <xsl:choose> | |
32 <xsl:when test="count($schemas) < count($schemas | $includes)"> | |
33 <!-- when $includes includes something new, recurse ... --> | |
34 <xsl:call-template name="gatherSchema"> | |
35 <!-- ... with current $includes added to the $schemas parameter ... --> | |
36 <xsl:with-param name="schemas" select="$schemas | $includes"/> | |
37 <!-- ... and any *new* includes in the $include parameter --> | |
38 <xsl:with-param name="includes" | |
39 select="document($includes/xs:schema/xs:*[self::xs:include or self::xs:import or self::xs:redefine]/@schemaLocation)"/> | |
40 </xsl:call-template> | |
41 </xsl:when> | |
42 <xsl:otherwise> | |
43 <!-- we have the complete set of included schemas, | |
44 so now let's output the embedded schematron --> | |
45 <xsl:call-template name="output"> | |
46 <xsl:with-param name="schemas" select="$schemas"/> | |
47 </xsl:call-template> | |
48 </xsl:otherwise> | |
49 </xsl:choose> | |
50 </xsl:template> | |
51 <!-- --> | |
52 <!-- output the schematron information --> | |
53 <!-- --> | |
54 <xsl:template name="output"> | |
55 <xsl:param name="schemas"/> | |
56 <!-- --> | |
57 <sch:schema> | |
58 <!-- get header-type elements - eg title and especially ns --> | |
59 <!-- title (just one) --> | |
60 <xsl:copy-of select="$schemas//xs:appinfo/sch:title[1]"/> | |
61 <!-- get remaining schematron schema children --> | |
62 <!-- get non-blank namespace elements, dropping duplicates --> | |
63 <xsl:for-each select="$schemas//xs:appinfo/sch:ns"> | |
64 <xsl:if test="generate-id(.) = | |
65 generate-id($schemas//xs:appinfo/sch:ns[@prefix = current()/@prefix][1])"> | |
66 <xsl:copy-of select="."/> | |
67 </xsl:if> | |
68 </xsl:for-each> | |
69 <xsl:copy-of select="$schemas//xs:appinfo/sch:phase"/> | |
70 <xsl:copy-of select="$schemas//xs:appinfo/sch:pattern"/> | |
71 <sch:diagnostics> | |
72 <xsl:copy-of select="$schemas//xs:appinfo/sch:diagnostics/*"/> | |
73 </sch:diagnostics> | |
74 </sch:schema> | |
75 </xsl:template> | |
76 <!-- --> | |
77 </xsl:transform> |