I have some complex XSLT 2.0 transformations. I'm trying to find out if there is general purpose way to ensure that no empty tags are output. So... conceptually, a final stage of processing that recursively removes all empty tags. I understand this could be done by a separate XSLT that did nothing but filter out empty tags, but I need to have it all packaged together in a single one.
相关问题
- XML - XSLT - document() function inside count() fu
- Using XSLT to select after EACH instance in a stri
- XSLT open other xml files
- How to use MSbuild property in TransformXml task?
- Using asp objects in .NET - Max compatibility
相关文章
- xslt localization
- convert xml to soap request using xslt transformat
- XALAN register Extension Function like in SAXON
- How to group using XSLT
- How to reformat XML with group-adjacent (XSLT)
- AddExtensionObject - Performance
- Transforming HTML nodes with XSLT in chrome/webkit
- visual studio 2015 xsl debugging transformation fa
This XSLT 2.0 transformation illustrates how multi-pass (in this case 2-pass) processing can be done:
when applied on this XML document:
It creates a result document in the first pass (which is captured in the
$vPass1
variable), in which all<num>
elements with contents even integer are stripped off their content and are empty. Then, in the second pass, applied in a specific mode, all empty elements are removed.The result of the transformation is:
Do note the use of modes, and the special modes
#all
and#current
.Update: The OP now wants in a comment to delete "recursively" "all nodes that have no non-empty descendant".
This can be implemented simpler using no explicit recursion. Just change:
to: