now need to figure out consecutive magic
This commit is contained in:
parent
87ee8bcda7
commit
ee351722dc
|
@ -1,7 +1,7 @@
|
|||
<html>
|
||||
<body>
|
||||
<div>
|
||||
<h1>title</h1>
|
||||
<h1>title1</h1>
|
||||
<ul id="nav">
|
||||
<li>home</li>
|
||||
<li>about</li>
|
||||
|
@ -15,12 +15,12 @@
|
|||
<p>It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. </p>
|
||||
<p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
|
||||
<div id="comments">
|
||||
<h3>joe</h3>
|
||||
<h3>joe1</h3>
|
||||
<p>This sux!</p>
|
||||
<p>No, really; it's awful!!!</p>
|
||||
<h3>bob</h3>
|
||||
<h3>bob1</h3>
|
||||
<p>who uses semi-colons?</p>
|
||||
<h3>joe</h3>
|
||||
<h3>joe1.5</h3>
|
||||
<p>who hyphenates semicolon?</p>
|
||||
</div>
|
||||
</li>
|
||||
|
@ -29,13 +29,11 @@
|
|||
<p>I hate lipsum. It's hard to tell which post you're on.</p>
|
||||
<p>Obligatory second paragraph</p>
|
||||
<div id="comments">
|
||||
<h3>suzy</h3>
|
||||
<h3>suzy2</h3>
|
||||
<p>FRIST POST!!!</p>
|
||||
<h3>bob</h3>
|
||||
<h3>bob2</h3>
|
||||
<p>grow up</p>
|
||||
<p>2nd post</p>
|
||||
<h3>joe</h3>
|
||||
<p>i like peanuts.</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -22,64 +22,43 @@
|
|||
|
||||
<xsl:template match="/">
|
||||
<dexter:root xmlns:dexter="http://kylemaxwell.com/dexter">
|
||||
<page>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select="//h1">
|
||||
<xsl:variable name="index1" select="last() - position()" />
|
||||
<dexter:group>
|
||||
<title><xsl:value-of select="." /></title>
|
||||
<nav>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select="set:intersection(key('key1', $index1), //ul[@id='nav']//li)">
|
||||
<dexter:group>
|
||||
<xsl:value-of select="." />
|
||||
</dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</nav>
|
||||
<post>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select="set:intersection(key('key1', $index1), //*[@id='posts']//li)">
|
||||
<xsl:variable name="post" value="position()" />
|
||||
<dexter:group>
|
||||
<title><xsl:value-of select=".//h2" /></title>
|
||||
<paras>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select="./p">
|
||||
<dexter:group><xsl:value-of select="."/></dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</paras>
|
||||
<comments>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select=".//*[@id='comments']//h3">
|
||||
<xsl:variable name="index2" select="$index1 + (last() - position())" />
|
||||
<dexter:group>
|
||||
<title><xsl:value-of select="."/></title>
|
||||
<paras>
|
||||
<dexter:groups>
|
||||
<xsl:for-each select="set:intersection(key('key2', $index2), //p)">
|
||||
<dexter:group><xsl:value-of select="."/></dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</paras>
|
||||
</dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</comments>
|
||||
</dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</post>
|
||||
</dexter:group>
|
||||
</xsl:for-each>
|
||||
</dexter:groups>
|
||||
</page>
|
||||
<xsl:for-each select="//h1">
|
||||
<page>
|
||||
<xsl:variable name="page_index" select="last() - position()" />
|
||||
<xsl:attribute name="title"><xsl:value-of select="key('page-key', $page_index)/h1" /></xsl:attribute>
|
||||
|
||||
<xsl:for-each select="key('page-key', $page_index)/*[@id='posts']//li">
|
||||
<post>
|
||||
<xsl:attribute name="title"><xsl:value-of select=".//h2" /></xsl:attribute>
|
||||
<xsl:for-each select=".//*[@id='comments']//h3">
|
||||
<comment>
|
||||
<xsl:variable name="comment_index" select="count(set:intersection(following::*, //*[@id='comments']//h3))"/>
|
||||
<xsl:attribute name="index"><xsl:value-of select="$comment_index" /></xsl:attribute>
|
||||
<xsl:attribute name="ele"><xsl:value-of select="count(key('comment-title-key', $comment_index))" /></xsl:attribute>
|
||||
<xsl:attribute name="title"><xsl:value-of select="key('`', $comment_index)" /></xsl:attribute>
|
||||
|
||||
<xsl:for-each select="key('comment-paras-key', $comment_index)">
|
||||
<para><xsl:value-of select="."/></para>
|
||||
</xsl:for-each>
|
||||
</comment>
|
||||
</xsl:for-each>
|
||||
</post>
|
||||
</xsl:for-each>
|
||||
</page>
|
||||
</xsl:for-each>
|
||||
</dexter:root>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key name="key1" match="//*" use="count(following::h1)" />
|
||||
<xsl:key name="key2" match="//*" use="count(following::*[@id='comments']//h3)" />
|
||||
<xsl:template match="node()|@*">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:key name="page-key" match="//*" use="count(following::h1)" />
|
||||
<!-- <xsl:key name="post-key" match="//*" use="." /> -->
|
||||
<xsl:key name="comment-title-key" match="//*[@id='comments']//h3" use="count(set:intersection(following::*, //*[@id='comments']//h3))" />
|
||||
<xsl:key name="comment-paras-key" match="//*[@id='comments']//p" use="count(set:intersection(following::*, //*[@id='comments']//h3))" />
|
||||
|
||||
</xsl:stylesheet>
|
||||
|
||||
|
|
Loading…
Reference in New Issue