0

我有一个 xslt

<category numberofproducts="0">
  <id>Main</id>
  <url>/products/Main</url>
  <name>Main</name>
  <texts>
    <text language="standard">
      <name>Name</name>
      <longdescription></longdescription>
      <shortdescription></shortdescription>
      <htmltitle></htmltitle>
      <metadescription></metadescription>
      <metakeywords></metakeywords>
    </text>
  </texts>
  <name>Kopipapir</name>
  <longdescription></longdescription>
  <shortdescription></shortdescription>
  <htmltitle></htmltitle>
  <metadescription></metadescription>
  <metakeywords></metakeywords>
  <category numberofproducts="47">
    <id>Name1</id>
    <url>/products/Name1</url>
    <name>Name1, New</name>
    <texts>
      <text language="standard">
        <name>New, Nmae</name>
        <longdescription></longdescription>
        <shortdescription></shortdescription>
        <htmltitle></htmltitle>
        <metadescription></metadescription>
        <metakeywords></metakeywords>
      </text>
    </texts>
   </category>
  <category numberofproducts="23">
    <id>Name2</id>
    <url>/products/Name2</url>
    <name>Name2, hvd</name>
    <texts>
      <text language="standard">
        <name>Name2, hvd</name>
        <longdescription></longdescription>
        <shortdescription></shortdescription>
        <htmltitle></htmltitle>
        <metadescription></metadescription>
        <metakeywords></metakeywords>
      </text>
    </texts>
   </category>

我需要检查类别中有类别

我尝试过类似的东西..

<xsl:choose>
      <xsl:when test="$ccat/category//category != '' ">

          <xsl:text >Category</xsl:text>

      </xsl:when>
      <xsl:otherwise>
        <xsl:text>Listing</xsl:text>
      </xsl:otherwise>
    </xsl:choose>

有人帮忙吗?

4

1 回答 1

1

我在下面的回答,假设您希望检查类别根下是否存在任何类别子项

<xsl:if test="boolean(/category//category)='true'">
    <xsl:text>Category</xsl:text>
</xsl:if>
于 2015-10-07T13:34:57.510 回答