Skip to content

Commit

Permalink
Better validation for anyElement/@require.
Browse files Browse the repository at this point in the history
  • Loading branch information
hcayless committed Jan 8, 2017
1 parent 590f80a commit 5b465b7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions odds/odd2relax.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,9 @@ of this software, even if advised of the possibility of such damage.
</choice>
</zeroOrMore>
</element>
<xsl:if test="@require and ancestor::tei:elementSpec and
not(ancestor::tei:content//tei:elementRef)">
<xsl:if test="@require and ancestor::tei:elementSpec">
<xsl:variable name="ns"><xsl:if
test="ancestor::tei:content//tei:*">, 'http://www.tei-c.org/ns/1.0'</xsl:if></xsl:variable>
<xsl:variable name="computed-prefix">
<xsl:for-each select="in-scope-prefixes($current)">
<xsl:if test="$spec/@ns = namespace-uri-for-prefix(., $current)">
Expand All @@ -422,8 +423,12 @@ of this software, even if advised of the possibility of such damage.
<xsl:if test="$spec/@ns"><ns xmlns="http://purl.oclc.org/dsdl/schematron" prefix="{$prefix}" uri="{ancestor::tei:elementSpec/@ns}"/></xsl:if>
<pattern xmlns="http://purl.oclc.org/dsdl/schematron" id="{concat(generate-id(),'-constraint')}">
<rule context="{$prefix}:{ancestor::tei:elementSpec/@ident}">
<report test="descendant::*[not(namespace-uri(.) = ({concat($apos,string-join(tokenize(current()/@require, ' '),concat($apos,', ',$apos)),$apos)}))]">
<xsl:value-of select="ancestor::tei:elementSpec/@ident"/> content must be in the namespace<xsl:if test="contains(@include, ' ')">s</xsl:if><xsl:text> </xsl:text><xsl:value-of select="concat($apos,string-join(tokenize(current()/@include, ' '),concat($apos,', ',$apos)),$apos)"/></report>
<report test="descendant::*[not(namespace-uri(.) =
({concat($apos,string-join(tokenize(current()/@require, ' '),concat($apos,', ',$apos)),$apos,$ns)}))]">
<xsl:value-of select="ancestor::tei:elementSpec/@ident"/> descendants must be in the
namespace<xsl:if test="contains(@require, ' ') or $ns ne ''">s</xsl:if><xsl:text>
</xsl:text><xsl:value-of select="concat($apos,string-join(tokenize(current()/@require,
' '),concat($apos,', ',$apos)),$apos,$ns)"/></report>
</rule>
</pattern>
</xsl:if>
Expand Down

0 comments on commit 5b465b7

Please sign in to comment.