xslt中的选择

xslt中的选择,xslt,Xslt,嗨,我有下面的xml <primaryie> <content-style font-style="bold">VIRRGIN system 7.204, 7.205</content-style> </primaryie> VIRRGIN系统7.204、7.205 通过应用下面的xslt,我可以选择数字 <xsl:value-of select="current()/text()"/> 但在下面的例子中

嗨,我有下面的xml

 <primaryie>
  <content-style font-style="bold">VIRRGIN system 7.204, 7.205</content-style> 
  </primaryie>

VIRRGIN系统7.204、7.205
通过应用下面的xslt,我可以选择数字

<xsl:value-of select="current()/text()"/>

但在下面的例子中

    <primaryie>
  <content-style font-style="bold">VIRRGIN system</content-style> 
  7.204, 7.205 
  </primaryie>

VIRRGIN系统
7.204, 7.205 
如何选择号码?我想要类似于使用xslt的东西:内容样式的父级

还有一些情况下,这两个XML结合在一起。如果两种情况都存在,请让我知道如何选择号码


谢谢

我认为使用类似于下面的模板设计应该会有所帮助:

<xsl:template match="primaryie">
    <!-- Do some stuffs here, if needed -->
    <!-- With the node() function you catch elements and text nodes (* just catch elements) -->
    <xsl:apply-templates select="node()"/>
</xsl:template>

<xsl:template match="content-style">
    <!-- Do some stuffs here, if needed -->
    <!-- same way -->
    <xsl:apply-templates select="node()"/>
</xsl:template>

<!-- Here you got the template which handle the text nodes. It's probably better to add the ancestor predicate to limit its usage to the only text nodes we need to analyze ('cause the xslt processor often has some silent calls to the embedded default template <xsl:template match="text()"/> and override it completely could have some spectacular collaterall damages). -->
<xsl:template match="text()[ancestor::primaryie]">
   <!-- Do your strings 'cooking' here -->
</xsl:template>


或者,或者

<xsl:template match="content-style">
  <xsl:value-of select="../text()"/>
</xsl:template>

使用

<xsl:template match="primaryie/text()">
  <!-- Processing of the two numbers here -->
</xsl:template>
<xsl:template match="primaryi">
  <!-- Any necessary processing, including this: -->
  <xsl:apply-templates select="text()"/>
</xsl:template>
<xsl:template match="primaryi">
  <!-- Any necessary processing, including this: -->
  <xsl:apply-templates select="text()"/>
</xsl:template>