Skip to content

Commit

Permalink
more progres on generating technique index
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-n-cooper committed May 24, 2018
1 parent 4f5ff45 commit 67d0699
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 15 deletions.
12 changes: 12 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<target name="clean" description="Clean up any temp files">
<delete file="${inputdir.guidelines}/index-flat.html" failonerror="false"/>
<delete file="${inputdir.guidelines}/wcag21.xml" failonerror="false"/>
<delete file="${inputdir.techniques}/techniques.xml" failonerror="false"/>
<delete file="output.html" failonerror="false"/>
<delete dir="output" failonerror="false"/>
</target>
Expand All @@ -50,6 +51,17 @@
</xslt>
</target>

<!-- Techniques -->
<target name="techniques-xml" depends="flatten, guidelines-xml" description="Build an XML structure of all techniques">
<makeurl file="${basedir}/techniques" property="techniques.dir"/>
<makeurl file="${basedir}/understanding" property="understanding.dir"/>
<xslt in="${inputdir.guidelines}/wcag21.xml" out="${inputdir.techniques}/techniques.xml" style="xslt/generate-technique-xml.xslt">
<factory name="${xslt.factory}"/>
<param name="techniques.dir" expression="${techniques.dir}"/>
<param name="understanding.dir" expression="${understanding.dir}"/>
</xslt>
</target>

<!-- Understanding -->
<target name="understanding" depends="guidelines-xml" description="Generate formatted Understanding docs">
<makeurl file="${basedir}/understanding/" property="base.understanding"/>
Expand Down
15 changes: 0 additions & 15 deletions xslt/generate-structure-xml.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

<xsl:include href="base.xslt"/>

<xsl:param name="techs.dir">techniques/</xsl:param>

<xsl:output method="xml" indent="yes"/>

<xsl:template name="id">
Expand Down Expand Up @@ -114,17 +112,4 @@
</term>
</xsl:template>

<xsl:template match="html:a[starts-with(@href, 'https://www.w3.org/WAI/WCAG21/Techniques/')]">
<xsl:variable name="tech-technology" select="replace(@href, '^.*/([\w-]*)/[\w\d]*$', '$1')"/>
<xsl:variable name="tech-id" select="replace(@href, '^.*/([\w\d]*)$', '$1')"/>
<xsl:variable name="tech-path" select="concat('../techniques/', $tech-technology, '/', '$tech-id', '.html')"/>
<xsl:variable name="tech-doc" select="document(resolve-uri($tech-path, $techs.dir))"/>
<technique>
<id><xsl:value-of select="$tech-id"/></id>
<technology><xsl:value-of select="$tech-technology"/></technology>
<title><xsl:value-of select="$tech-doc//html:h1"/></title>
<file href="{$tech-technology}/{$tech-id}"/>
</technique>
</xsl:template>

</xsl:stylesheet>
51 changes: 51 additions & 0 deletions xslt/generate-technique-xml.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:wcag="https://www.w3.org/WAI/GL/"
exclude-result-prefixes="xs"
version="2.0">

<xsl:import href="base.xslt"/>

<xsl:output method="xml" indent="yes"/>

<xsl:param name="techniques.dir">techniques/</xsl:param>
<xsl:param name="understanding.dir">understanding/</xsl:param>

<xsl:template match="guidelines">
<techniques>
<xsl:apply-templates select="//guideline | //success-criterion"/>
</techniques>
</xsl:template>

<xsl:template match="guideline | success-criterion">
<xsl:variable name="subpath">
<xsl:choose>
<xsl:when test="version = 'WCAG20'">20/</xsl:when>
<xsl:when test="version = 'WCAG21'">21/</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:apply-templates select="document(resolve-uri(concat(file/@href, '.html'), concat($understanding.dir, $subpath)))">
<xsl:with-param name="meta" select="." tunnel="yes"/>
</xsl:apply-templates>
</xsl:template>

<xsl:template match="html:html">
<xsl:apply-templates select="descendant::html:section[@id = 'techniques']//html:a"/>
</xsl:template>

<xsl:template match="html:a[starts-with(@href, 'https://www.w3.org/WAI/WCAG21/Techniques/')]">
<xsl:variable name="tech-technology" select="replace(@href, '^.*/([\w-]*)/[\w\d]*$', '$1')"/>
<xsl:variable name="tech-id" select="replace(@href, '^.*/([\w\d]*)$', '$1')"/>
<xsl:variable name="tech-path" select="concat('../techniques/', $tech-technology, '/', $tech-id, '.html')"/>
<xsl:variable name="tech-doc" select="document(resolve-uri($tech-path, $techniques.dir))"/>
<technique>
<id><xsl:value-of select="$tech-id"/></id>
<technology><xsl:value-of select="$tech-technology"/></technology>
<title><xsl:value-of select="$tech-doc//html:h1"/></title>
<file href="{$tech-technology}/{$tech-id}"/>
</technique>
</xsl:template>

</xsl:stylesheet>

0 comments on commit 67d0699

Please sign in to comment.