Xsl when is empty




















There is no programming for if branches. Note: there is no such thing as null in XML. Yes xsi: nil , but it is rarely used, especially in the untyped scene without a certain pattern. Programmer Group A programming skills sharing group. For example, if the categoryName is empty?

What I use when selecting constructs is. Learn more about bidirectional Unicode characters. This comment has been minimized.

Sign in to view. Copy link Quote reply. Now I've put a condition to the second and is only running in case the first one failed Thanks again. Great, Thanks a lot. Continue this way Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Asked 12 years, 6 months ago.

Active 7 months ago. Viewed k times. Improve this question. Isaac G Sivaa 1, 4 4 gold badges 14 14 silver badges 32 32 bronze badges. Can you expand the code example? Depending on your use-case, you probably don't want to use xsl:when for node-tests.

The processor will then make the correct decisions for you and you do not need to write out the business logic in nested xsl:choose anymore. In many cases, using matching templates makes writing stylesheets easier.

Add a comment. Active Oldest Votes. Improve this answer. The detailed semantics of this test is: return true if there is at least one categoryName element whose string value is an empty string. I'm an xsl newbie, so forgive any potential stupidity to my question. This answer, while accepted and highly voted, is also very misleading. It really depends what you mean by "null or empty". The supplied answer will return false if the categoryName element is absent, which in my interpretation of the question makes it a wrong answer.

MichaelKay: I've updated the answer to provide more details. Show 5 more comments. Dirk Vollmar k 53 53 gold badges silver badges bronze badges. It's appreciated that you included multiple examples to show how each expression results. Instead, you only deal with nodes, or elements in this case, which is the whole between start-tag and end-tag.

I starred the question specifically for this answer, and while the question is pretty old, this one seems much more deserving of being the selected answer — Patrick. From Empty Element : To test if the value of a certain node is empty It depends on what you mean by empty. Contains no child nodes: not node Contains no text content: not string. Contains no text other than whitespace: not normalize-space. Contains nothing except comments: not node [not self::comment ].

Mads Hansen 56k 12 12 gold badges silver badges bronze badges. Chris Doggett Chris Doggett Some notes. The first bulletpoint also tests for text-content, which is also a node.

The second bulletpoint tests for any text node at any depth, if you want to know if the current node does not contain text, but can contain other nodes, you can use not text.



0コメント

  • 1000 / 1000