[英]How can I select those element which have no text children
In document below I am trying to get those element have no text child. 在下面的文档中,我试图使那些元素没有文本子级。 but every effort get nothing. 但一切努力都无济于事。
<a>
<b>
<c> this is nice place </c>
</b>
<d>
<e> where this place is </e>
<f> this place is very close to us</f>
</d>
<g>
<h/>
</g>
<i/>
</a>
Stylesheet that copies empty elements (immediate children of a
) and their children, if there's not a single text node: 样式表副本空元素(立即儿童a
)和他们的孩子,如果有不是一个单一的文本节点:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:apply-templates select="a"/>
</xsl:template>
<xsl:template match="a">
<empty>
<xsl:copy-of select="*[not(node()/text())]"/>
</empty>
</xsl:template>
</xsl:stylesheet>
Result: 结果:
<?xml version="1.0" encoding="utf-8"?>
<empty>
<g>
<h />
</g>
<i />
</empty>
所以,如果我理解正确的话,你希望所有的孩子a
不具有文本节点?
/a/element()[not(.//text())]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.