Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.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
Javascript 排除xml节点_Javascript_Xml_Xslt - Fatal编程技术网

Javascript 排除xml节点

Javascript 排除xml节点,javascript,xml,xslt,Javascript,Xml,Xslt,我被困在一些你可能认为很简单的事情中 在xml文件中,我有这些节点 <Types> <Pas type="1" single="Man" plural="Men" /> <Pas type="2" single="Woman" plural="Women" description="this is a test" /> <Pas type="3" single="Child" plural="Children" description="th

我被困在一些你可能认为很简单的事情中

在xml文件中,我有这些节点

<Types>
  <Pas type="1" single="Man" plural="Men" />
  <Pas type="2" single="Woman" plural="Women" description="this is a test" />
  <Pas type="3" single="Child" plural="Children" description="this is another test" />
</Types>
问题是我不想让男人有这种感觉

有没有办法排除它


问候

您可以添加如下xsl:if语句:

<xsl:if test="@description">
     (<xsl:value-of select="$Details/@desc" />)* 
</xsl:if>

()* 

您只需输入以下特定代码:

(<xsl:value-of select="$Details/@description" />)*
()*
变成条件语句,例如

<xsl:if test='current()/@description and string-length(current()/@description) > 0'>
  (<xsl:value-of select="$Details/@description" />)*
</xsl:if>

()*

请注意,这也会处理空属性。

谢谢,伙计。它是这样工作的()*注意,这个测试表达式相当于更短的
test=“string(@description)”
@LarsH+1不知道:)
<xsl:if test="@description">
     (<xsl:value-of select="$Details/@desc" />)* 
</xsl:if>
(<xsl:value-of select="$Details/@description" />)*
<xsl:if test='current()/@description and string-length(current()/@description) > 0'>
  (<xsl:value-of select="$Details/@description" />)*
</xsl:if>