XSL跟踪&x27;盲点';多通道xslt中的按行号

XSL跟踪&x27;盲点';多通道xslt中的按行号,xslt,xalan,Xslt,Xalan,我之前的一个类似问题是:“通过多个xsl转换跟踪源元素”,但我正在寻找一种方法来跟踪失败/成功编译的xsl/xml文件行号等等。我有多个通过受模板“模式”限制。同时,我可以就问题的根源寻求帮助: 在多通道XSL中,Pass1使用文件“XSLT1”转换MSWord(2003)标记,该文件包括文件“XSLT2”,该文件通过2个连接拆分节点,现在Pass3中的意图(由于文件包含问题,位于XSLT2中)是将“干净”xml分组/重新排列为SQL DDL,但在Pass3中没有识别任何内容 顺便说一句,我正在

我之前的一个类似问题是:“通过多个xsl转换跟踪源元素”,但我正在寻找一种方法来跟踪失败/成功编译的xsl/xml文件行号等等。我有多个通过受模板“模式”限制。同时,我可以就问题的根源寻求帮助:

在多通道XSL中,Pass1使用文件“XSLT1”转换MSWord(2003)标记,该文件包括文件“XSLT2”,该文件通过2个连接拆分节点,现在Pass3中的意图(由于文件包含问题,位于XSLT2中)是将“干净”xml分组/重新排列为SQL DDL,但在Pass3中没有识别任何内容

顺便说一句,我正在通过--NetBeansIDE(8.0.2)com.sun.org.apache.xalan.internal.xsltc.compiler.EqualityExpr尝试这一点 “它只是在控制台上声明:例如,在编译错误上: 无法强制转换为com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern-无文件/行号上下文-此转换有多个文件,至少有三个过程,其中pass3似乎是我当前的问题。 现在来看细节——经过两遍之后,我得到了我想要进一步处理的格式良好的中间xml:(中间xml在实际的xml文件中以“Document/Body/Section/Segment”开头)

顺便提一下,下面的pass2输出在第一段中暗指DB表名,后面是表限定符,然后是第一列段中的列名,其余段中的行值:

<Document>
<Body>
<Section>
<Segment frags="1" size="32">
<Entry ycoord="1.40" xcoord="1.1" size="32" frags="1" desgn="Table">TEACHING AND LEARNING EXPERIENCE</Entry>
</Segment>
<Segment frags="1" size="25">
<Entry ycoord="2.40" xcoord="1.1" frags="1" size="25" desgn="Table">UNIVERSITY MODULES TAUGHT</Entry>
</Segment>
<Segment>
<Entry ycoord="3.40" xcoord="1.6" desgn="Column">Module(Full title and code – not abbreviated)</Entry>
<Entry ycoord="3.40" xcoord="2.6" desgn="Column">Level(Indicate year level, if graduate module, otherwise Honours or Masters)</Entry>
<Entry ycoord="3.40" xcoord="3.6" desgn="Column">University</Entry>
<Entry ycoord="3.40" xcoord="4.6" desgn="Column">From(mm/yyyy)</Entry>
<Entry ycoord="3.40" xcoord="5.6" desgn="Column">To(mm/yyyy)</Entry>
<Entry ycoord="3.40" xcoord="6.6" desgn="Column">Total period</Entry>
</Segment>
<Segment frags="7" size="87">
<Entry ycoord="4.40" xcoord="1.6 desgn="Column">Transport planning 201</Entry>
<Entry ycoord="4.40" xcoord="2.6" desgn="Column">Undergraduate</Entry>
<Entry ycoord="4.40" xcoord="3.6" desgn="Column">University of LLL</Entry>
<Entry ycoord="4.40" xcoord="4.6" desgn="Column">January 2011</Entry>
<Entry ycoord="4.40" xcoord="5.6" desgn="Column">-</Entry>
<Entry ycoord="4.40" xcoord="6.6" desgn="Column">3 years &amp; 2Months</Entry>
</Segment>
<Segment frags="6" size="98">
<Entry ycoord="5.40" xcoord="1.6" desgn="Column">RI Planning 202</Entry>
<Entry ycoord="5.40" xcoord="2.6" desgn="Column">Undergraduate</Entry>
<Entry ycoord="5.40" xcoord="3.6" desgn="Column">University of LLL</Entry>
<Entry ycoord="5.40" xcoord="4.6" desgn="Column">January 2011</Entry>
<Entry ycoord="5.40" xcoord="5.6" desgn="Column">December 2012</Entry>
<Entry ycoord="5.40" xcoord="6.6" desgn="Column">2 years</Entry>
</Segment>
<Segment frags="6" size="96">
<Entry ycoord="6.40" xcoord="1.6" desgn="Column">LG and Civil Society</Entry>
<Entry ycoord="6.40" xcoord="2.6" desgn="Column">Undergraduate</Entry>
<Entry ycoord="6.40" xcoord="3.6" desgn="Column">University of LLL</Entry>
<Entry ycoord="6.40" xcoord="4.6" desgn="Column">July 2010</Entry>
<Entry ycoord="6.40" xcoord="5.6" desgn="Column">-</Entry>
<Entry ycoord="6.40" xcoord="6.6" desgn="Column">3 years &amp; 7 Months</Entry>
</Segment>
<Segment frags="6" size="101">
<Entry ycoord="7.40" xcoord="1.6" desgn="Column">LGCS 242</Entry>
<Entry ycoord="7.40" xcoord="2.6" desgn="Column">UG/Entry>
<Entry ycoord="7.40" xcoord="3.6" desgn="Column">University of LLL</Entry>
<Entry ycoord="7.40" xcoord="4.6" desgn="Column">July 2010</Entry>
<Entry ycoord="7.40" xcoord="5.6" desgn="Column">December 2013</Entry>
<Entry ycoord="7.40" xcoord="6.6" desgn="Column">3 years</Entry>
</Segment>
</Section>
</Body>
</Document>

教学经验
大学模块教学
模块(完整标题和代码-不缩写)
级别(如果是研究生模块,请注明年份级别,否则为荣誉或硕士)
大学
自(年月日)
至(年月日)
总周期

我已经成功地将上述内容(在第20行和第50行中修复错别字后)分别转换为missing“和missing<,使用以下内容,但不作为包含的文件(原始问题):


""
并获得:

<?xml version="1.0" encoding="utf-8"?>
<Document>
<Segment frags="1" size="32">
<Entry ycoord="1.40" xcoord="1.1" size="32" frags="1" desgn="Table">"TEACHING AND LEARNING EXPERIENCE"</Entry>
</Segment>
<Segment frags="1" size="25">
<Entry ycoord="2.40" xcoord="1.1" frags="1" size="25" desgn="Table">"UNIVERSITY MODULES TAUGHT"</Entry>
</Segment>
<Segment>
<Entry ycoord="3.40" xcoord="1.6" desgn="Column">"Module(Full title and code – not abbreviated)""Level(Indicate year level, if graduate module, otherwise Honours or Masters)""University""From(mm/yyyy)""To(mm/yyyy)""Total period"</Entry>
</Segment>
<Segment frags="7" size="87">
<Entry ycoord="4.40" xcoord="1.6" desgn="Column">"Transport planning 201""Undergraduate""University of LLL""January 2011""-""3 years &amp; 2Months"</Entry>
</Segment>
<Segment frags="6" size="98">
<Entry ycoord="5.40" xcoord="1.6" desgn="Column">"RI Planning 202""Undergraduate""University of LLL""January 2011""December 2012""2 years"</Entry>
</Segment>
<Segment frags="6" size="96">
<Entry ycoord="6.40" xcoord="1.6" desgn="Column">"LG and Civil Society""Undergraduate""University of LLL""July 2010""-""3 years &amp; 7 Months"</Entry>
</Segment>
<Segment frags="6" size="101">
<Entry ycoord="7.40" xcoord="1.6" desgn="Column">"LGCS 242""UG""University of LLL""July 2010""December 2013""3 years"</Entry>
</Segment>
</Document>

“教学经验”
“大学模块教学”
“模块(全称和代码-不缩写)”“级别(如果是研究生模块,则表示年份级别,否则表示荣誉或硕士)”“大学”“从(mm/yyyy)”到(mm/yyyy)”“总期限”
“交通规划201”“本科”“法学大学”“2011年1月”“3年及2个月”
“国际扶轮规划202”“本科”“法学学士”“2011年1月”“2012年12月”“2年”
“LG与民间社会”“本科”“法学大学”“2010年7月”“3年7个月”
“LGCS 242”“UG”“法学学士学位”“2010年7月”“2013年12月”“三年”
下一个障碍: 我需要将属性改为在第一列名称行之后。 以下是我在文档第4部分中一直在努力解决的问题(我省略了身份设计前言):


罗瓦尔斯

它除去了除text()以外的所有内容,而不是将“Column”简单地替换为“RowVals”。非常感谢您的帮助。

我不知道您的问题是什么。“我正在寻找一种跟踪失败/成功编译的xsl/xml文件行号的方法”通常,如果在解析xml文件或通过XSLT处理xml文件时出错,处理器将通过(至少)行号向您发送一条错误消息,指示有问题的代码。然而,处理器不是一个读心术的人:如果你的模板与源XML不匹配,就不会抛出错误。只是回答我模糊/困惑的问题的最初部分,我希望有一种方法可以跟踪翻译器a-la JavaCC的进度,例如,可以跟踪“扫描器”命中或更详细的“解析器”命中。在这方面我似乎找不到类似的实用程序。这将有助于发现新手在优先级、优先级、轴心等方面的错误(我认为);运行时源代码,以及运行时前编译错误xls。仅回答我模糊/困惑问题的最初部分,我希望有一种方法可以跟踪翻译程序a-la JavaCC的进度,例如,可以跟踪“扫描程序”命中或更详细的“解析器”命中。我在这方面似乎找不到类似的用途。这将有助于发现新手在优先级、优先级、轴心等方面的错误(我认为);运行时,除了预运行时编译错误之外。标识模式样式表的xsl:include似乎不能在一个include之外重复。如果解析器要按预期工作,则中间的过程必须是非身份的。我结束对这一观察的提问。
<xsl:transform>
<!-- ... -->
<xsl:template match="*" mode="pass3">
    <xsl:copy>
       <!-- have tried numerous other patterns to match here -->
       <xsl:apply-templates mode="pass3" select="Document/Body/Section/Segment/Entry"/>
    </xsl:copy>
</xsl:template>
<!-- one of many failed attempts at transforming pass2 output -->
<xsl:template match="Entry" mode="pass3">
    <xsl:value-of select="local-name()"/>
     <xsl:value-of select="@desgn"/>       
      <xsl:value-of select="."/>
</xsl:template>
</xsl:transform>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exslt="http://exslt.org/common"
exclude-result-prefixes="xsl exslt w aml wpc dt mc o v w10 wx wne wsp sl">

<xsl:output method="xml" encoding="utf-8" indent="yes"/>


<xsl:template match="/" mode="pass3">
    <xsl:variable name="pass3Out">
        <xsl:apply-templates select="@* | node()" mode="pass3"/>
    </xsl:variable>
    <xsl:variable name="pass3Node" select="exslt:node-set($pass3Out)"/>
    <xsl:apply-templates select="$pass3Node/*" mode="pass4"/>
</xsl:template>

<xsl:template match="/" >
    <xsl:apply-templates select="Document" mode="pass3"/>
</xsl:template>


<xsl:template match="Document" mode="pass3">
    <xsl:copy>
        <xsl:apply-templates select="Meta" />
        <xsl:apply-templates select="Body/Logo" />
        <xsl:apply-templates select="Body/Prelim" />
        <xsl:apply-templates select="Body/Section" />
    </xsl:copy>
</xsl:template>


<xsl:template match="Meta" >
    <xsl:copy>
        <xsl:apply-templates select="text()" />
    </xsl:copy>
</xsl:template>

<xsl:template match="Body/Logo" >
    <xsl:copy>
        <xsl:apply-templates select="text()" />
    </xsl:copy>
</xsl:template>

<xsl:template match="Segment" >
    <xsl:copy>
        <xsl:copy-of select="@*"/>
        <xsl:for-each select="Entry[not(@ycoord = preceding-sibling::Entry/@ycoord)]">
            <xsl:variable name="Coord" select="@ycoord"/>
            <xsl:copy>
                <xsl:copy-of select="@*"/>
                <xsl:for-each select="../Entry[@ycoord = $Coord]">"<xsl:value-of select="."/>"</xsl:for-each>
            </xsl:copy>
        </xsl:for-each>
    </xsl:copy>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="utf-8"?>
<Document>
<Segment frags="1" size="32">
<Entry ycoord="1.40" xcoord="1.1" size="32" frags="1" desgn="Table">"TEACHING AND LEARNING EXPERIENCE"</Entry>
</Segment>
<Segment frags="1" size="25">
<Entry ycoord="2.40" xcoord="1.1" frags="1" size="25" desgn="Table">"UNIVERSITY MODULES TAUGHT"</Entry>
</Segment>
<Segment>
<Entry ycoord="3.40" xcoord="1.6" desgn="Column">"Module(Full title and code – not abbreviated)""Level(Indicate year level, if graduate module, otherwise Honours or Masters)""University""From(mm/yyyy)""To(mm/yyyy)""Total period"</Entry>
</Segment>
<Segment frags="7" size="87">
<Entry ycoord="4.40" xcoord="1.6" desgn="Column">"Transport planning 201""Undergraduate""University of LLL""January 2011""-""3 years &amp; 2Months"</Entry>
</Segment>
<Segment frags="6" size="98">
<Entry ycoord="5.40" xcoord="1.6" desgn="Column">"RI Planning 202""Undergraduate""University of LLL""January 2011""December 2012""2 years"</Entry>
</Segment>
<Segment frags="6" size="96">
<Entry ycoord="6.40" xcoord="1.6" desgn="Column">"LG and Civil Society""Undergraduate""University of LLL""July 2010""-""3 years &amp; 7 Months"</Entry>
</Segment>
<Segment frags="6" size="101">
<Entry ycoord="7.40" xcoord="1.6" desgn="Column">"LGCS 242""UG""University of LLL""July 2010""December 2013""3 years"</Entry>
</Segment>
</Document>
<xsl:template match="Segment" mode="pass4">
    <xsl:copy>
        <xsl:choose>
            <xsl:when test="Entry[@desgn='Column'] and preceding-sibling::Entry[@desgn = 'Table']">
               <xsl:for-each select="following-sibling::*/Entry[@desgn = 'Column']">
                  <xsl:copy-of select="@ycoord" /><xsl:copy-of select="@xcoord" />
                  <xsl:attribute name="desgn">RowVals</xsl:attribute>
               </xsl:for-each>
            </xsl:when>
        <xsl:otherwise>
        <xsl:copy-of select="@*|node()"/>
        </xsl:otherwise>
        </xsl:choose>
    </xsl:copy>
</xsl:template>