Recursive property in XSLT when the property contains CDATA (property never empty)?
Hi!
I'm working on a solution where a page that does not have a user set value for a particular property should continue looking up the node tree until it finds a page where the property is set.
According to this answer on Stackoverflow, an empty CDATA is equal to an empty tag? Is this still true for umbraco? If so, what is wrong with my code?
The property is present on all pages on the site since it's part of my master doctype. So the script will always find the property. But only a few pages have a value set for this property. If a page doesn't have a value set it should look at it's parent. And if the parent doesn't have it either, it should look at its parent and so on all the way up to the homepage.
A CDATA Section is nothing but a (very) special way of marking up something that's not to be parsed as anything else but text - so an "empty" CDATA Section is the same as an empty element (tag).
The best way to test for that is using the normalize-space() function... meanwhile, your variable ends up selecting the document node, not the bannerImage property, so here's the XPath needed to "fix" it:
I realize that my example was not complete - I did have a continued path to the actual property. But the normalize-space function was what made the difference!
Recursive property in XSLT when the property contains CDATA (property never empty)?
Hi!
I'm working on a solution where a page that does not have a user set value for a particular property should continue looking up the node tree until it finds a page where the property is set.
I found this example:
The problem in my case is that the property "bannerImage" is never empty. Instead it looks like this:
The result is that the XSLT above doesn't work as it's supposed to - it never continues looking up the node tree since the string is never empty.
How do I handle this?
Regards,
Thomas
Or?
According to this answer on Stackoverflow, an empty CDATA is equal to an empty tag?
Is this still true for umbraco? If so, what is wrong with my code?
The property is present on all pages on the site since it's part of my master doctype. So the script will always find the property. But only a few pages have a value set for this property. If a page doesn't have a value set it should look at it's parent. And if the parent doesn't have it either, it should look at its parent and so on all the way up to the homepage.
/Thomas
Hi Thomas,
A CDATA Section is nothing but a (very) special way of marking up something that's not to be parsed as anything else but text - so an "empty" CDATA Section is the same as an empty element (tag).
The best way to test for that is using the normalize-space() function... meanwhile, your variable ends up selecting the document node, not the bannerImage property, so here's the XPath needed to "fix" it:
/Chriztian
Hi Chriztian!
I realize that my example was not complete - I did have a continued path to the actual property. But the normalize-space function was what made the difference!
Thanks!
/Thomas
is working on a reply...