Diff for 12013 design
Fri, 2008-06-13 05:42 by imagiczhang | Fri, 2008-06-13 05:58 by imagiczhang | ||
---|---|---|---|
< previous diff | next diff > | ||
Changes to Body | |||
Line 20 | Line 20 | ||
</p>
| </p>
| ||
<p>
| <p>
| ||
- | <xsl:param name="WORKDIR"/><br />
| + | <xsl:param name="WORKDIR"/><br />
|
- | <xsl:param name="conref-source-topicid"/><br />
| + | <xsl:param name="conref-source-topicid"/><br />
|
- | <xsl:param name="conref-ids"/><br />
| + | <xsl:param name="conref-ids"/><br />
|
- | <xsl:param name="source-element"/><br />
| + | <xsl:param name="source-element"/><br />
|
- | <xsl:param name="current-relative-path"/> <!-- File system path from original file to here --><br />
| + | <xsl:param name="current-relative-path"/> <!-- File system path from original file to here --><br />
|
- | <xsl:param name="conref-filename"/><br />
| + | <xsl:param name="conref-filename"/><br />
|
.......calculate topic id and element id..........
| .......calculate topic id and element id..........
| ||
</p>
| </p>
| ||
<p>
| <p>
| ||
- | <!-- If for some bizarre reason you conref to another element that uses @conref, forget the original and continue here. -->
| + | <!-- If for some bizarre reason you conref to another element that uses @conref, forget the original and continue here. -->
|
</p>
| </p>
| ||
<p>
| <p>
| ||
<xsl:choose><br />
| <xsl:choose><br />
| ||
- | <xsl:when test="@conref"><br />
| + | <xsl:when test="@conref"><br />
|
.......proceed @conref of the conref target.........<br />
| .......proceed @conref of the conref target.........<br />
| ||
- | </xsl:when><br />
| + | </xsl:when><br />
|
- | <xsl:otherwise><br />
| + | <xsl:otherwise><br />
|
- | <xsl:for-each select="@*"><br />
| + | <xsl:for-each select="@*"><br />
|
- | .......proceed every @* attribute.........<br />
| + | .......proceed every @* attribute.........<br />
|
- | </xsl:for-each><br />
| + | </xsl:for-each><br />
|
- | <br />
| + | <br />
|
- | <!-- Continue processing this element as any other --><br />
| + | <!-- Continue processing this element as any other --><br />
|
- | <xsl:apply-templates select="*|comment()|processing-instruction()|text()"><br />
| + | <xsl:apply-templates select="*|comment()|processing-instruction()|text()"><br />
|
- | ......apply templates on sub-nodes.......<br />
| + | ......apply templates on sub-nodes.......<br />
|
- | </xsl:apply-templates><br />
| + | </xsl:apply-templates><br />
|
- | </xsl:otherwise><br />
| + | </xsl:otherwise><br />
|
- | </xsl:choose>
| + | </xsl:choose>
|
</p>
| </p>
| ||
<p>
| <p>
| ||
Line 57 | Line 57 | ||
<p>
| <p>
| ||
</xsl:template>
| </xsl:template>
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | |||
+ | <strong>How to address the elements in the conref range?</strong>
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | If @conrefend is valid, there must be a following sibling to the conref target which has the same id as @conrefend specified. If @conrefend is not valid, we would ignore @conrefend and report a warning message saying that @conrefend is not valid. If valid, we should use following XPath expression to address all of the elements between conref start and conref end.
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | following-sibling::*[following-sibling::*[@id=$conrefend-elem-id]]
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | This XPath expression is used to address all of the following siblings to current conref target with condition that @conrefend element is also their following sibling.
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | We created a sample demo to prove that this XPath can be accepted by XSLT processor. Here is the demo.
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | ***********1.xml************
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | <?xml version="1.0" encoding="UTF-8"?><br />
| ||
+ | <stub><br />
| ||
+ | <li id="a"></li><br />
| ||
+ | <li id="b"></li><br />
| ||
+ | <li id="c"></li><br />
| ||
+ | <li id="d"></li><br />
| ||
+ | <li id="e"></li><br />
| ||
+ | <li id="f"></li><br />
| ||
+ | <li id="g"></li><br />
| ||
+ | <li id="h"></li><br />
| ||
+ | <li id="i"></li><br />
| ||
+ | <li id="k"></li><br />
| ||
+ | </stub>
| ||
</p>
| </p>
| ||
<p>
| <p>
| ||
|
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | ********2.xsl***********
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | <?xml version="1.0" encoding="UTF-8"?><br />
| ||
+ | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><br />
| ||
+ | <xsl:template match="/"><br />
| ||
+ | <xsl:for-each select="/stub/*[preceding-sibling::*[@id='a']][following-sibling::*[@id='g']]"><br />
| ||
+ | <xsl:copy><br />
| ||
+ | <xsl:copy-of select="@*|*|text()|comment()|processing-instruction()"/><br />
| ||
+ | </xsl:copy><br />
| ||
+ | </xsl:for-each><br />
| ||
+ | </xsl:template><br />
| ||
+ | </xsl:stylesheet>
| ||
+ | </p>
| ||
+ | <p>
| ||
+ | In this demo, 2.xsl get all elements between a and g and copy them to the output.
| ||
</p>
| </p>
| ||
<p>
| <p>
|
12013 design
Design for item
What user need will be met by this feature?
Users can use @conref combined with @conrefend to refer to a range of sibling elements and pull them into the specified location.
What is the technical design for the change
In conrefImpl.xsl, when the target of @conref is processed, the code first copy or proceed all @* attributes of target elements and then use apply-templates on its sub-nodes. After that we need to add the code to check whether @conrefend is valid and proceed the elements in the conref range. Since the template to proceed conref target doesn't know whether there is @conrefend at conref source, the value of @conrefend should be passed as parameter.
Here is the current template to proceed conref-target in conrefImpl.xsl with update comments in bold
<xsl:template match="*" mode="conref-target">
**************** We need to add a parameter here to accept the value of @conrefend. The default value is #none# which means that there is no @conrefend ***************************
<xsl:param name="WORKDIR"/>
<xsl:param name="conref-source-topicid"/>
<xsl:param name="conref-ids"/>
<xsl:param name="source-element"/>
<xsl:param name="current-relative-path"/> <!-- File system path from original file to here -->
<xsl:param name="conref-filename"/>
.......calculate topic id and element id..........
<!-- If for some bizarre reason you conref to another element that uses @conref, forget the original and continue here. -->
<xsl:choose>
<xsl:when test="@conref">
.......proceed @conref of the conref target.........
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="@*">
.......proceed every @* attribute.........
</xsl:for-each>
<!-- Continue processing this element as any other -->
<xsl:apply-templates select="*|comment()|processing-instruction()|text()">
......apply templates on sub-nodes.......
</xsl:apply-templates>
</xsl:otherwise>
</xsl:choose>
***************************************************************
Here we need to add the logic to proceed @conrefend if the value of @conrefend is sent to this template as variable.
***************************************************************
</xsl:template>
How to address the elements in the conref range?
If @conrefend is valid, there must be a following sibling to the conref target which has the same id as @conrefend specified. If @conrefend is not valid, we would ignore @conrefend and report a warning message saying that @conrefend is not valid. If valid, we should use following XPath expression to address all of the elements between conref start and conref end.
following-sibling::*[following-sibling::*[@id=$conrefend-elem-id]]
This XPath expression is used to address all of the following siblings to current conref target with condition that @conrefend element is also their following sibling.
We created a sample demo to prove that this XPath can be accepted by XSLT processor. Here is the demo.
***********1.xml************
<?xml version="1.0" encoding="UTF-8"?>
<stub>
<li id="a"></li>
<li id="b"></li>
<li id="c"></li>
<li id="d"></li>
<li id="e"></li>
<li id="f"></li>
<li id="g"></li>
<li id="h"></li>
<li id="i"></li>
<li id="k"></li>
</stub>
********2.xsl***********
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:for-each select="/stub/*[preceding-sibling::*[@id='a']][following-sibling::*[@id='g']]">
<xsl:copy>
<xsl:copy-of select="@*|*|text()|comment()|processing-instruction()"/>
</xsl:copy>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
In this demo, 2.xsl get all elements between a and g and copy them to the output.
What sections of the toolkit will be impacted by the change?
The change will impact conref resolution xslt script.
See also
none