Skip to content

Commit

Permalink
re-doing the XPath case study with a better approach
Browse files Browse the repository at this point in the history
git-svn-id: https://slps.svn.sourceforge.net/svnroot/slps@817 ab42f6e0-554d-0410-b580-99e487e6eeb2
  • Loading branch information
grammarware committed Jul 11, 2010
1 parent 0ff5b88 commit ca2a844
Show file tree
Hide file tree
Showing 4 changed files with 1,636 additions and 1 deletion.
2 changes: 1 addition & 1 deletion shared/xsd/ldf.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<xsd:complexType>
<xsd:sequence>
<xsd:element name="title" type="xsd:string"/>
<xsd:choice>
<xsd:choice minOccurs="0">
<xsd:element name="version" type="xsd:string"/>
<xsd:element name="edition" type="xsd:string"/>
</xsd:choice>
Expand Down
2 changes: 2 additions & 0 deletions topics/documents/xpath/Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
build:
xsltproc spec2ldf.xslt xpath-pp.xml > xpath1.ldf

get:
curl -k http://www.w3.org/TR/1999/REC-xpath-19991116.xml >xpath1.xml
curl -k http://www.w3.org/TR/2007/REC-xpath20-20070123/xpath20.xml >xpath2.xml
curl -k http://www.w3.org/XML/1998/06/xmlspec-v20.dtd > xmlspec-v20.dtd

clean:
*~
80 changes: 80 additions & 0 deletions topics/documents/xpath/spec2ldf.xslt
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bgf="http://planet-sl.org/bgf" xmlns:ldf="http://planet-sl.org/ldf" version="1.0">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="/spec">
<ldf:document xmlns:ldf="http://planet-sl.org/ldf">
<ldf:title-page>
<xsl:if test="header/w3c-doctype">
<ldf:body>w3c</ldf:body>
<number>
<xsl:value-of select="header/w3c-designation"/>
</number>
</xsl:if>
<ldf:metainfo>
<xsl:copy-of select="header/title"/>
<xsl:for-each select="header/authlist/author">
<author>
<xsl:value-of select="name"/>
</author>
</xsl:for-each>
</ldf:metainfo>
<xsl:choose>
<xsl:when test="header/w3c-doctype = 'W3C Recommendation'">
<ldf:status>approved</ldf:status>
</xsl:when>
<xsl:otherwise>
<ldf:status>unknown</ldf:status>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="header/version = 'Version 1.0'">
<version>1.0</version>
</xsl:when>
<xsl:when test="header/version = 'Version 2.0'">
<version>2.0</version>
</xsl:when>
<xsl:otherwise>
<version>
<xsl:value-of select="header/version"/>
</version>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="header/prevlocs/loc">
<ldf:previous>
<title>
<xsl:choose>
<xsl:when test="substring(text(),1,7) = 'http://'">
<xsl:value-of select="substring-after(substring-after(substring-after(text(),'http://www.w3.org/'),'/'),'/')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="text()"/>
</xsl:otherwise>
</xsl:choose>
</title>
<uri>
<xsl:value-of select="@href"/>
</uri>
</ldf:previous>
</xsl:for-each>
<date>
<xsl:value-of select="header/pubdate/day"/>
<xsl:text> </xsl:text>
<xsl:value-of select="header/pubdate/month"/>
<xsl:text> </xsl:text>
<xsl:value-of select="header/pubdate/year"/>
</date>
</ldf:title-page>
<ldf:part>
<role>front-matter</role>
<ldf:metainfo>
<title>Status of this document</title>
</ldf:metainfo>
<content>
<simple-section>
<xsl:copy-of select="header/status"/>
</simple-section>
</content>
</ldf:part>
</ldf:document>
</xsl:template>
</xsl:stylesheet>
Loading

0 comments on commit ca2a844

Please sign in to comment.