Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xpath 如何匹配案例并应用模板_Xpath_Xslt 2.0 - Fatal编程技术网

Xpath 如何匹配案例并应用模板

Xpath 如何匹配案例并应用模板,xpath,xslt-2.0,Xpath,Xslt 2.0,下面是XML代码行 <title><page>651</page>CHAPTER 13 This is <content-style font-style="italic">This goes in content-style</content-style> The title</title> 忽略标题中的页面,我使用下面的模板匹配并能够做到这一点 <xsl:template match="title/page"/&

下面是XML代码行

<title><page>651</page>CHAPTER 13 This is <content-style font-style="italic">This goes in content-style</content-style> The title</title>
忽略标题中的页面,我使用下面的模板匹配并能够做到这一点

<xsl:template match="title/page"/>
预期O/p

你能告诉我怎么做吗


谢谢

您的预期输出有一个不匹配的span-end标记

忽略这一点,我会这样做:

<xsl:template match ="title">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="content-style">
        <span class="font-style-{@font-style}">
            <xsl:value-of select="."/>
        </span>
</xsl:template>

<xsl:template match="title/text()">
  <xsl:analyze-string select="." regex="Chapter [0-9]+">
    <xsl:matching-substring>
      <span class="chapter-num">
       <xsl:value-of select="."/>
      </span><br/>>br/>
    </xsl:matching-substring>
    <xsl:non-matching-substring>
       <xsl:value-of select="."/>
    </xsl:-nonmatching-substring>
  </xsl:analyze-string>
</xsl:template>

子字符串after的结果是一个字符串,而不是一个节点,在XSLT 3.0将模板应用于字符串之前,您不能这样做。与其告诉我们你正在做什么失败了,不如告诉我们你正在试图解决什么问题:你的转换的输入和输出是什么?如果没有这些信息,我们只能告诉你,无论你想做什么,你都是走错了路。嗨@MichaelKay,我已经更新了,我的问题嗨Michael Kay,很抱歉延迟回复,这不是预期的效果。这是工作演示,你能看一下吗。谢谢
<xsl:value of select ="substring-after(substring-after(./title,' '),' ')">
<xsl:template match ="title">
<xsl:apply-templates/>
</xsl:template>
    <xsl:template match="content-style">
        <xsl:variable name="fontStyle">
            <xsl:value-of select="concat('font-style-',@font-style)"/>
        </xsl:variable>
        <span class="{$fontStyle}">
            <xsl:value-of select="."/>
            <xsl:apply-templates select="para"/>
        </span>
    </xsl:template>
<div class="chapter-title">
                    <span class="chapter-num">Chapter 13</span><br /><br /> This is <span class="font-style-italic">This goes in content-style</span> the title</span></div>
<xsl:template match ="title">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="content-style">
        <span class="font-style-{@font-style}">
            <xsl:value-of select="."/>
        </span>
</xsl:template>

<xsl:template match="title/text()">
  <xsl:analyze-string select="." regex="Chapter [0-9]+">
    <xsl:matching-substring>
      <span class="chapter-num">
       <xsl:value-of select="."/>
      </span><br/>>br/>
    </xsl:matching-substring>
    <xsl:non-matching-substring>
       <xsl:value-of select="."/>
    </xsl:-nonmatching-substring>
  </xsl:analyze-string>
</xsl:template>