1

下面的 XSL 将提取“磁焦点的作用”。但现在我必须修改 xsl 以便输入标签必须作为 args 传递。

输入 XML:

<w:document>
   <w:body>
        <w:p>
            <w:pPr>
              <w:pStyle w:val="articletitle"/>
            </w:pPr>
            <w:r>
                 <w:t>The Role of Magnetic Focus</w:t>
            </w:r>
        </w:p>
        <w:p>
            <w:pPr>
              <w:pStyle w:val="paragraph"/>
            </w:pPr>
            <w:r>
                <w:t>All is well</w:t>
            </w:r>
        </w:p>
        </w:body>
</w:document>

XSL

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
>
<xsl:output method="text"/>
<xsl:template match="w:p"/>
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val[matches(., concat('^(articletitle)$'),'i')]]"> 
    <xsl:value-of select="."/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

我修改了上面的 xsl 如下,但我无法获得所需的输出

  <?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
 xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
>

<xsl:param name="styleName" select="articletitle"/>
<xsl:param name="para" select="w:p"/>
<xsl:param name="parastyle" select="w:pPr/w:pStyle/@w:val"/>

<xsl:output method="text"/>
<xsl:template match="@* | node()">
    <xsl:copy>
        <xsl:apply-templates select="@* | node()"/>
         <xsl:choose>
            <xsl:when test="name() = $para">
            <xsl:message><xsl:value-of select="name()"/></xsl:message>
                <xsl:value-of select="name()"/>
             </xsl:when>
         </xsl:choose>
    </xsl:copy>
</xsl:template>

</xsl:stylesheet>

请帮忙.....

4

1 回答 1

1

只需更改

<xsl:param name="para" select="w:p"/>

到:

<xsl:param name="para" select="'w:p'"/>
于 2012-10-29T12:59:39.050 回答