Skip to content

Commit

Permalink
Tweeks to HTML model.
Browse files Browse the repository at this point in the history
Fixing IDs in JSON schema per issue #933.
Initial calabash XProc implementation.
  • Loading branch information
david-waltermire committed May 20, 2021
1 parent 16a32f8 commit b1b6593
Show file tree
Hide file tree
Showing 7 changed files with 379 additions and 31 deletions.
22 changes: 22 additions & 0 deletions scripts/include/init-saxon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ init_saxon() {
fi
SAXON_HOME=~/.m2/repository/net/sf/saxon/Saxon-HE/$SAXON_VERSION
fi

if [[ -z "$CALABASH_HOME" ]]; then
echo -e "${P_ERROR}CALABASH_HOME is not set or is empty.${P_END} ${P_INFO}Please set SAXON_VERSION to indicate the library version or SAXON_HOME to point to the location of the Saxon library.${P_END}"
fi
}

# ( set -o posix ; set )
Expand Down Expand Up @@ -45,4 +49,22 @@ xsl_transform() {
return 0
}

run_calabash() {
local xproc="$1"; shift
local extra_params=($@)

local JARS=()
JARS+=("$CALABASH_HOME"/*.jar)
JARS+=("$CALABASH_HOME"/lib/*.jar)

local classpath=$(IFS=:; echo -e "${JARS[*]}")

java -cp "$classpath" com.xmlcalabash.drivers.Main -D "${extra_params[@]}" "$xproc"

if [ "$?" -ne 0 ]; then
echo -e "${P_ERROR}Error running Calabash.${P_END}"
return 3
fi
return 0
}

4 changes: 2 additions & 2 deletions toolchains/xslt-M4/document/common-reference.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<xsl:param name="applying-to" select="parent::*"/>
<xsl:variable name="constraints" select=".//allowed-values | .//matches | .//has-cardinality | .//is-unique | .//index-has-key | .//index"/>
<xsl:where-populated>
<!--<details>
<!-- <details>
<summary>Constraints</summary>
<xsl:apply-templates mode="produce-matching-constraints" select="$constraints">
<xsl:with-param name="applying-to" select="$applying-to"/>
</xsl:apply-templates>
</details>-->
</xsl:where-populated>
--> </xsl:where-populated>

</xsl:template>

Expand Down
21 changes: 11 additions & 10 deletions toolchains/xslt-M4/document/json/object-reference-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,30 @@
</xsl:variable>

<xsl:template match="/*">
<div>
<div class="json-reference">
<xsl:apply-templates/>
</div>
</xsl:template>

<xsl:template match="schema-name"/>

<xsl:template match="schema-version" expand-text="true">
<h2><span class="usa-tag">Schema version:</span> { . }</h2>
<p><span class="usa-tag">Schema version:</span> { . }</p>
</xsl:template>

<xsl:template match="*[exists(@key)]" expand-text="true">
<xsl:param tunnel="true" name="constraints" select="()"/>
<xsl:variable name="level" select="count(ancestor-or-self::*[exists(@key)])"/>
<section class="json-obj">
<xsl:call-template name="crosslink-to-xml"/>
<!-- generates h1-hx headers picked up by Hugo toc -->
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="h{ $level }" expand-text="true">
<xsl:attribute name="id" select="@_tree-json-id"/>
<xsl:attribute name="class">toc{ $level} head</xsl:attribute>
<xsl:text>{ @key }</xsl:text>
</xsl:element>

<div class="header">
<xsl:call-template name="crosslink-to-xml"/>
<!-- generates h1-hx headers picked up by Hugo toc -->
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="h{ $level }" expand-text="true">
<xsl:attribute name="id" select="@_tree-json-id"/>
<xsl:attribute name="class">toc{ $level} head</xsl:attribute>
<xsl:text>{ @key }</xsl:text>
</xsl:element>
</div>
<xsl:sequence expand-text="true">
<p>See <a href="{ $json-map-link }#{ @_tree-json-id }">{ @_tree-json-id }</a> in the object map.</p>
</xsl:sequence>
Expand Down
22 changes: 12 additions & 10 deletions toolchains/xslt-M4/document/xml/element-reference-html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<xsl:variable name="xml-map-link" select="$path-to-common || $xml-map-page"/>

<xsl:template match="/*">
<div>
<div class="xml-reference">
<!--<details><summary>XML source</summary>
<pre>
<xsl:value-of select="serialize(.,$indenting)"/>
Expand All @@ -49,15 +49,17 @@
<xsl:param tunnel="true" name="constraints" select="()"/>
<xsl:variable name="level" select="count(ancestor-or-self::*[exists(@gi)])"/>
<section class="xml-element">
<xsl:call-template name="json-crosslink"/>

<!-- generates h1-hx headers picked up by Hugo toc -->
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="h{ $level }" expand-text="true">
<!-- XXX LINK HERE -->
<xsl:attribute name="id" select="@_tree-xml-id"/>
<xsl:attribute name="class">toc{ $level} head</xsl:attribute>
<xsl:text>{ self::attribute/'@' || @gi }</xsl:text>
</xsl:element>
<div class="header">
<xsl:call-template name="json-crosslink"/>

<!-- generates h1-hx headers picked up by Hugo toc -->
<xsl:element namespace="http://www.w3.org/1999/xhtml" name="h{ $level }" expand-text="true">
<!-- XXX LINK HERE -->
<xsl:attribute name="id" select="@_tree-xml-id"/>
<xsl:attribute name="class">toc{ $level} head</xsl:attribute>
<xsl:text>{ self::attribute/'@' || @gi }</xsl:text>
</xsl:element>
</div>
<xsl:sequence expand-text="true">
<p>See <a href="{$xml-map-link}#{@_tree-xml-id}">{ @_tree-xml-id }</a> in the element map.</p>
</xsl:sequence>
Expand Down
Loading

0 comments on commit b1b6593

Please sign in to comment.