1

それでも私は以下のエラーが発生しています

Error at xsl:param on line 6 of file:/E:/saxon/parastyleText.xsl:
  XPST0003: XPath syntax error at char 0 on line 6 in {...le/@w:val[matches(., c
oncat...}:
    Invalid character '^' in expression
Failed to compile stylesheet. 1 error detected.

変更された 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="tagName" select="'//w:p[w:pPr/w:pStyle/@w:val[matches(., concat('^(',$styleName,')$'),'i')]]'"/>

    <xsl:output method="text"/>

    <xsl:template match="/">
        <xsl:value-of select="saxon:evaluate($tagName)" xmlns:saxon="http://saxon.sf.net/"/><xsl:text>&#10;</xsl:text>
    </xsl:template>

    </xsl:stylesheet>

返信しないでください。引用符は「tagName」を文字列として作成し、それらの引用符を削除します。この値は、実際には文字列として Java から渡されます。テスト目的で、この xpath を文字列として渡しました。

4

1 に答える 1

0

オンライン ドキュメントhttp://www.saxonica.com/documentation9.1/extensions/functions.htmlによると、Saxon 9.1 はSaxon 名前空間evaluatehttp://saxon.sf.net/関数をサポートしています。だからSaxon 9.1で試してみてください<xsl:value-of select="saxon:evaluate($tagName)" xmlns:saxon="http://saxon.sf.net/"/>。もちろん、必要に応じて名前空間宣言をxsl:stylesheet要素に移動することもできxsl:value-ofます。コードの短いが完全なサンプルとして、この投稿でそれを配置しました。

また、変数に名前tagNameを付けると、要素名が 1 つしかない可能性が高いことに注意してください。その場合は、<xsl:value-of select="*[local-name() eq $tagName]"/>.

于 2012-11-01T11:36:25.387 に答える