Short about my aim. I want to parse a xlm file with Saxon and at the end get a text file with code.
Something like this:
function1(){
a+a;}
function2(){
b+b;}
function3(){
c+c;}
My Idea is to create Such code using <apply>
template tag so that for each facing a <tr>
tag, a text file would be fullfiled with necessary methods that are in <td>
tags. For example for each first child of <tr>
is a function1().
Here are the errors:
Warning
XTDE0540: Ambiguous rule match for /html/body[1]/table[1]
Matches both
"document-node()/element(Q{http://www.w3.org/1999/xhtml}html)/element(Q{http://www.w3.org/1999/xhtml}body)/element(Q{http://www.w3.org/1999/xhtml}table)" on line 71 of file:/C:/Users/fleonov/Desktop/test_for_thomas/Var_05_02/transfer_html.xsl
and "document-node()/element(Q{http://www.w3.org/1999/xhtml}html)/element(Q{http://www.w3.org/1999/xhtml}body)/element(Q{http://www.w3.org/1999/xhtml}table)" on line 21 of file:/C:/Users/fleonov/Desktop/test_for_thomas/Var_05_02/transfer_html.xsl
<?xml version="1.0" encoding="UTF-8"?>
Use_Cases
<br xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml"/><p
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xhtml="http://www.w3.org/1999/xhtml">function1()<br/>
{<br/><br/>function1()<br/>
But each time I see such thing(in different variations).
Here is mine xlt and xml code:
<xsl:template match="/html/body/table" >
<xsl:variable name="main_file" select="concat(lower-case(../h1),'_stimuli')"/>
<xsl:result-document href="{$main_file}.h" method="text">`
{
<xsl:apply-templates select="/html/body/table" /> //I put apply template here because it is not
possible to use
<template> inside a <result-document>
</xsl:result-document>
</xsl:template>
<xsl:template match="/html/body/table" name="code">
<xsl:apply-templates select="/html/body/table/tr" />
</xsl:template>
<xsl:template match="/html/body/table/tr" >
<xsl:apply-templates select="child::td[2]" />
<xsl:apply-templates select="child::td[3]" />
<xsl:apply-templates select="child::td[4]" />
</xsl:template>
<xsl:template match="child::td[2]">
<br></br>
<p>function1()<br></br>
{<br></br>
<xsl:value-of select="." /><br></br>
}<br></br>
</p>
</xsl:template>
<xsl:template match="child::td[3]"><br></br>
<p>function2()<br></br>
{<br></br>
<xsl:value-of select="." /><br></br>
}<br></br>
</p>
</xsl:template>
<xsl:template match="child::td[4]"><br></br>
<p>function3()<br></br>
{<br></br>
<br></br>
<xsl:value-of select="." /><br></br>
}<br></br>
</p>
</xsl:template>
</xsl:stylesheet>
Here is mine html that I parse.
<body>
<h1>Use_Cases</h1>
<table border="1">
<tr>
<td>file_name</td>
<td>function1()</td>
<td>function2()</td>
<td>function3()</td>
<td>function4()</td>
<td></td>
</tr>
<tr>
<td>test</td>
<td>a+a;</td>
<td>b+b;</td>
<td>c+c;</td>
<td>d+d;</td>
<td></td>
</tr>
</table>
</body>
</html>
Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…