Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
attr. rules check assert valid attr. values.
  • Loading branch information
EsGeh authored and EsGeh committed Jul 29, 2019
1 parent 782717c commit 56ecd9d
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 2 deletions.
Expand Up @@ -42,7 +42,7 @@
<text>invalid content for </text>
<copy-of select="$unique_xpath_expr_str"/>
<text>. expected:</text>
<apply-templates mode="rng_to_rnc" select="eoa:rng/rng:define"/>
<apply-templates mode="rng_to_rnc" select="eoa:rng_no_attributes/rng:define"/>
</value-of>
</with-param>
</call-template>
Expand Down
Expand Up @@ -69,7 +69,111 @@
</otherwise>
</choose>
</variable>
<value-of select="concat( '@', $ns_prefix, rng:name )"/>
<variable name="attr_name" as="xs:string" select="concat($ns_prefix, rng:name)"/>
<apply-templates mode="attribute_condition" select="*[not(self::rng:name)]">
<with-param name="attr_name" select="$attr_name"/>
</apply-templates>
<!--
<choose>
<when test="rng:data">
<variable name="datatype_prefix" as="xs:string">
<choose>
<when test="rng:data/@datatypeLibrary = 'http://www.w3.org/2001/XMLSchema-datatypes'">
<text>xs:</text>
</when>
<otherwise>
<value-of select="eoa:debug(eoa:warning(), concat('no namespace prefix datatype library ', rng:data/@datatypeLibrary))"/>
</otherwise>
</choose>
</variable>
<value-of>
<value-of select="concat( '@', $ns_prefix, rng:name )"/>
<value-of select="concat( ' castable as ', concat( $datatype_prefix, rng:data/@type ) )"/>
</value-of>
</when>
<when test="rng:value/@type = 'token'">
<for-each select="rng:value[@type = 'token']">
<value-of>
<value-of select="concat( '@', $ns_prefix, rng:name )"/>
<text> = '</text>
<value-of select="."/>
<text>'</text>
</value-of>
</for-each>
<for-each select="rng:value[@type != 'token']">
<message>
<value-of select="eoa:debug(eoa:warning(), concat('unknown rng:value type ', rng:value/@type))"/>
</message>
</for-each>
</when>
<otherwise>
<message>
<value-of select="eoa:debug(eoa:warning(), concat('no rule to check attribute ', rng:name))"/>
</message>
<text> 1 </text>
</otherwise>
</choose>
-->
</template>

<template mode="attribute_condition" match="rng:data" as="xs:string">
<param name="attr_name" as="xs:string"/>
<variable name="datatype_prefix" as="xs:string">
<choose>
<when test="@datatypeLibrary = 'http://www.w3.org/2001/XMLSchema-datatypes'">
<text>xs:</text>
</when>
<otherwise>
<message>
<value-of select="eoa:debug(eoa:warning(), concat('no namespace prefix datatype library ', @datatypeLibrary))"/>
</message>
<text/>
</otherwise>
</choose>
</variable>
<value-of>
<value-of select="concat( '@', $attr_name )"/>
<value-of select="concat( ' castable as ', concat( $datatype_prefix, @type ) )"/>
</value-of>
</template>

<template mode="attribute_condition" match="rng:value[@type = 'token']" as="xs:string">
<param name="attr_name" as="xs:string"/>
<value-of>
<value-of select="concat( '@', $attr_name )"/>
<text> = '</text>
<value-of select="."/>
<text>'</text>
</value-of>
</template>

<template mode="attribute_condition" match="rng:text" as="xs:string">
<param name="attr_name" as="xs:string"/>
<value-of select="concat( '@', $attr_name )"/>
</template>

<template mode="attribute_condition" match="rng:choice" as="xs:string">
<param name="attr_name" as="xs:string"/>
<value-of>
<text>(</text>
<for-each select="*">
<apply-templates mode="attribute_condition" select=".">
<with-param name="attr_name" select="$attr_name"/>
</apply-templates>
<if test="position() != last()">
<text> or </text>
</if>
</for-each>
<text>)</text>
</value-of>
</template>

<template mode="attribute_condition" match="*" as="xs:string">
<param name="attr_name" as="xs:string"/>
<message>
<value-of select="eoa:debug(eoa:warning(), concat('no rule to check attribute ', $attr_name))"/>
</message>
<value-of select="concat( '@', $attr_name )"/>
</template>

<template mode="rng_to_xpath_cond_attributes_impl" match="rng:empty" as="xs:string">
Expand Down

0 comments on commit 56ecd9d

Please sign in to comment.