Skip to content

Commit

Permalink
removed dated commented or stale code, improve comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
EsGeh authored and EsGeh committed Aug 5, 2019
1 parent 2b4e5e6 commit 55097a5
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 197 deletions.
127 changes: 2 additions & 125 deletions stylesheets/rng_to_odd/analysis_to_odd.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
<import href="common/utils.xsl"/>
<import href="common/print.xsl"/>
<import href="common/rng_to_rnc.xsl"/>
<!--
<import href="rnc_analyse/unfold_refs.xsl"/>
-->
<import href="analysis_to_odd/define_to_schematron.xsl"/>

<param name="modules" as="xs:string*" select="('tei','header','core','textstructure')"/>
<param name="analysis_dir" as="xs:string" required="yes"/>
<param name="input_filename" required="yes"/>
<param name="print_rng" as="xs:boolean" select="true()"/>

<!-- param verbosity: see rng_analyse/print.xsl -->
<!-- debug printing params: see 'common/print.xsl' -->

<output
name="xml_output"
Expand All @@ -51,10 +48,6 @@

<value-of select="eoa:debug(concat('input_dir: ', $analysis_dir))"/>

<!--
<variable name="rng_simple" select="document(concat($analysis_dir, '/1_simple.xml'))/*"/>
-->

<!-- actual output -->
<result-document format="xml_output">
<call-template name="tei_document">
Expand All @@ -76,14 +69,11 @@
<!-- *************************** -->

<template name="document_content">
<!--
<param name="rng_simple"/>
-->
<element name="div" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">Specification</element>
<element name="schemaSpec" namespace="{$tei_namespace}">
<attribute name="ident">ODDfromRnc</attribute>
<!-- modules: -->
<!-- modules: -->
<for-each select="$modules">
<element name="moduleRef" namespace="{$tei_namespace}">
<attribute name="key"><value-of select="."/></attribute>
Expand Down Expand Up @@ -166,7 +156,6 @@

<!-- context: eoa:define -->
<template name="print_definition" as="element()*">

<!-- as defined in rnc: -->
<if test="$print_rng">
<for-each select="rng:define">
Expand Down Expand Up @@ -209,99 +198,8 @@
</when>
</choose>
</element>
<!--
<element name="p" namespace="{$tei_namespace}">
<text>!!WARNING: no unique xpath expression found!</text>
</element>
-->
</otherwise>
</choose>

<!-- TODO: contexts: -->
<!--
<choose>
<when test="$unique_xpath_expr">
<element name="p" namespace="{$tei_namespace}">
<text>unique xpath expression: '</text>
<value-of select="$unique_xpath_expr"/>
<text>'</text>
</element>
</when>
<otherwise>
<element name="p" namespace="{$tei_namespace}">
<text>!!WARNING: no unique xpath expression found!</text>
</element>
</otherwise>
</choose>
-->

<!-- required attributes -->
<!--
<variable name="required_attributes" as="element()*">
<apply-templates mode="required_attributes"/>
</variable>
<if test="count($required_attributes) != 0">
<element name="list" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">required attributes:</element>
<for-each select="$required_attributes">
<element name="item" namespace="{$tei_namespace}">
<apply-templates mode="rng_to_rnc" select="."/>
</element>
</for-each>
</element>
</if>
-->

<!--
subrestrictions
<variable name="sub_restrictions" as="element()*">
<call-template name="find_subrestrictions">
<with-param name="definition_name" as="xs:string" select="@name"/>
</call-template>
</variable>
<if test="count($sub_restrictions) != 0">
<call-template name="print_subrestrictions">
<with-param name="restrictions" as="element()*" select="$sub_restrictions"/>
</call-template>
</if>
contexts
<variable name="contexts">
<call-template name="definition_contexts"/>
</variable>
<choose>
<when test="count($contexts/null:path) != 0">
<element name="list" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}"><text>contexts:</text></element>
<for-each select="$contexts/null:path">
<element name="item" namespace="{$tei_namespace}">
<value-of select="./null:e" separator="/"/>
</element>
</for-each>
</element>
</when>
<otherwise>
<element name="p" namespace="{$tei_namespace}">
<text>!!WARNING: no "context" element found!</text>
</element>
</otherwise>
</choose>
loops (unresolved contexts)
<if test="count($contexts/null:loop) != 0">
<element name="list" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">
<text>!!WARNING: unresolved contexts (loops):</text>
<value-of select="concat('(', count($contexts/null:loop), ')')"/>
</element>
<for-each select="$contexts/null:loop">
<element name="item" namespace="{$tei_namespace}">
<value-of select="./null:e" separator="/"/>
</element>
</for-each>
</element>
</if>
-->
</template>

<template name="print_rng" as="element()*">
Expand All @@ -313,27 +211,6 @@
</element>
</template>


<template name="print_subrestrictions">
<param name="restrictions" as="element()*"/>
<!--
find all definitions which are to be restricted
by this element
-->
<element name="list" namespace="{$tei_namespace}">
<element name="head" namespace="{$tei_namespace}">
<text>restrictions to subelements (</text>
<value-of select="count($restrictions)"/>
<text>)</text>
</element>
<for-each select="$restrictions">
<element name="item" namespace="{$tei_namespace}">
<value-of select="./null:e" separator="/"/>
</element>
</for-each>
</element>
</template>

<xsl:template name="tei_document"
xmlns="http://www.tei-c.org/ns/1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Expand Down
32 changes: 22 additions & 10 deletions stylesheets/rng_to_odd/analysis_to_odd/xpath_cond_from_rng.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
exclude-result-prefixes="tei rng f fcn xs null eoa sch"
>

<!--
<import href="utils.xsl"/>
-->

<!-- rng -> xpath condition -->

<!-- context: "eoa:define" -->
Expand All @@ -37,19 +33,35 @@
</value-of>

</template>

<!--
We want to build an xpath expression that returns true
if and only if the content of an element matches
some rng definition given.
The xpath expression works like a parser, that consumes
the elements children one after the other.
The current xpath context hereby contains
the last consumed token (here: element).
Such an expression can be build recursively
after the 'parser combinator' paradigm.
The resulting xpath expression might not be optimal
(e.g. could be simplified), but it works.
-->

<!-- note:
<!-- informal:
for every rng expression A:
cond(a) ::=
"an xpath expr, that,
given a context of the node
consumed last
cond(A) ::=
"an xpath expr that,
if the FOLLOWING elements match A
moves the context to the last node
that was consumed by A on success,
matching A.
(the empty sequence otherwise)"
-->

<!--
roughly, the xpath condition is recursively
constructed like this:
assume we can uniquely identify the current
"parent" element P by the condition cond(P)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
-->

<!-- rng -> xpath condition -->

<!-- precondition on the rng:
* should only contain attributes, no 'rng:ref' elements
* normalized such that the 'rng:choice' is always toplevel,
e.g.: "(acd | ace | bcd | bce)" but not "(a|b) c (d|e)"
-->

<!-- context: "eoa:define" -->
<template name="rng_to_xpath_cond_attributes" as="xs:string">
Expand Down
2 changes: 1 addition & 1 deletion stylesheets/rng_to_odd/common/print.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<import href="utils.xsl"/>
-->

<!-- overwrite this to enable module specific debug output -->
<!-- overwrite this to enable module specific debug output -->
<param name="debug_modules" as="xs:string*" select="()"/>

<!-- verbosity: 0: only errors, 1: warnings, 2: info, 3: debug -->
Expand Down
2 changes: 2 additions & 0 deletions stylesheets/rng_to_odd/common/utils.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

<import href="fxsl/f/func-curry.xsl"/>

<variable name="tei_namespace">http://www.tei-c.org/ns/1.0</variable>
<variable name="rng_namespace">http://relaxng.org/ns/structure/1.0</variable>
<variable
name="eoa_namespace"
as="xs:string"
Expand Down
2 changes: 0 additions & 2 deletions stylesheets/rng_to_odd/rng_to_analysis.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ as officially documented here: https://relaxng.org/spec.html#simple-syntax
indent="yes"
/>
<strip-space elements="*"/>
<variable name="tei_namespace">http://www.tei-c.org/ns/1.0</variable>
<variable name="rng_namespace">http://relaxng.org/ns/structure/1.0</variable>

<!-- entry point: -->
<template match="/">
Expand Down
29 changes: 0 additions & 29 deletions stylesheets/rng_to_odd/rng_to_analysis/rnc_analyse_structure.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,6 @@
<import href="xpath_unique_expr_simple.xsl"/>
<import href="xpath_unique_expr_advanced.xsl"/>

<!--
<import href="utils.xsl"/>
-->

<!-- output intermediate steps into this directory...: -->
<param name="output" required="yes"/>
<output
name="xml_output"
method="xml"
encoding="utf-8"
indent="yes"
/>
<output
name="text_output"
method="text"
encoding="utf-8"
indent="yes"
/>
<strip-space elements="*"/>
<variable name="tei_namespace">http://www.tei-c.org/ns/1.0</variable>
<variable name="rng_namespace">http://relaxng.org/ns/structure/1.0</variable>
<variable
name="eoa_namespace"
as="xs:string"
select="'http://www.edition-open-access.de/ns'"
/>

<template name="structure">
<element name="grammar" namespace="{$rng_namespace}">
<element name="start" namespace="{$rng_namespace}">
Expand Down Expand Up @@ -136,8 +109,6 @@
<value-of select="f:apply(f:print_path(), .)"/>
</for-each>
</variable>
<if test="$loops_str">
</if>
-->
<apply-templates mode="structure_advanced" select=".">
<with-param name="unique_xpath_expr" select="$unique_xpath_expressions_resolved"/>
Expand Down
5 changes: 0 additions & 5 deletions stylesheets/rng_to_odd/rng_to_analysis/simplify_flatten.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
<!-- *************************** -->

<template mode="flatten" match="rng:choice | rng:group | rng:interleave">
<!--
<if test="not(count(./*) = 2)">
<value-of select="eoa:error(concat('flattening: wrong number of children for ', name()))"/>
</if>
-->
<choose>
<when test="../name() != name()">
<copy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,6 @@
</for-each>
</with-param>
</call-template>
<!--
<if test="$debug_xpath_unique_expr_advanced">
<variable name="paths_as_str" as="xs:string">
<value-of separator=", ">
<for-each select="$paths">
<value-of select="f:apply(f:print_path(), .)"/>
<if test="position() != last()">
<text>, </text>
</if>
</for-each>
</value-of>
</variable>
<sequence select="eoa:debug('xpath_unique_expr_advanced', concat($depth, 'xpath_unique_expr_advanced_rec: param: ', $paths_as_str))"/>
</if>
-->

<!-- 'eoa:define' elements for which there is
no other 'eoa:define'
Expand Down Expand Up @@ -354,16 +339,6 @@
</eoa:problem>
</for-each-group>
</for-each>
<!--
<sequence select="$rec_result/eoa:problems/*"/>
-->
<!--
<for-each select="$rec_result/eoa:problems/*">
<eoa:problem>
<sequence select="."/>
</eoa:problem>
</for-each>
-->

</template>

Expand Down

0 comments on commit 55097a5

Please sign in to comment.