RE: [xsl] xsl:copy-of O.K. on RTF, but nothing on <EMPTY/> element content (?)

Subject: RE: [xsl] xsl:copy-of O.K. on RTF, but nothing on <EMPTY/> element content (?)
From: "William Reilly" <wreilly@xxxxxxxxxxx>
Date: Sun, 4 May 2003 08:28:38 -0400
1. Letting go... (RTF var and string-based test)
2. But a question about use of xsl:for-each re: RTF vars: can I avoid

1. Letting go... (RTF var and string-based test)
Thank you, Michael Kay (and Mike Harmaan as well).
I agree: nodeset var, and nodeset 'test' is best.
  That is how I am now doing it.
(Your suggested code tightened up mine even further, removing the need 
for an interim variable. Thanks.)

How To:
- Step 1. Nodeset var: Create the variable as a nodeset 'xsl:variable
    [instead of RTF 'build up' <xsl:variable> ... </xsl:variable>], 
- Step 2. Nodeset test: Then test with 'nodeset presence' (xsl:when
     [instead of string-based xsl:when test="not($myvar='')" ]

> But the reason I wrote in was to pursue understanding of a
hypothetical requirement: 
	- testing an RTF var, 
		- with a string-based 'test', 
			- against the (admittedly unusual) data of what
			  call "Empty Element Content Only (NO
Whitespace)" ("EECO-NW")  
			  Example: <markup><img src="pic.gif"/></markup>

I'm going to "let this go...", but here was my thinking:

(Optional Reading!)
That is, _if_ you (for some reason(?)) had to build up an RTF
[ see perhaps the entry in Michael Kay's book 'XSLT' (xsl:for-each
on "Changing the Current Node" ], 
is there a string-based 'test' that would catch the (admittedly unusual)

condition of EECO-NW? e.g. <markup><img src="pic.gif"/></markup>

I think the answer is No.

When I test this against the string-based <xsl:when
it does not perform correctly (in my estimation), as it believes 
nothing is there (?). 
If I introduce even a single space, then it does perform 
correctly: <markup> <img src="pic.gif"/></markup>.
[Likewise, another string-based test like 
<xsl:when test="not(string-length($myvar)=0)"> does exactly the same.]

== Something Of A Conclusion:
I'm getting the impression that seeing as the nodes created in this
have no content of string values, this is why no string test will find
anything there.  
(And I guess you would only get at the attribute values if you
ask for them (XPath ?) ?)

So, I'm going to let that one go...  :>)  
Again, I'll use nodesets and nodeset testing. Thanks, all.

2. But a question about use of xsl:for-each re: RTF vars: can I avoid
The RTF variable "build-up" seems most suited to xsl:for-each use.

>>  Q. What can be said about 'xsl:for-each select=' as compared to
'xsl:variable select=' 
(or 'xsl:apply-templates select=') ?

That is, setting aside two important concepts xsl:for-each can do for
(as delineated in Michael Kay's book 'XSLT'): 
	1. xsl:sort
	2. the use of xsl:for-each to "Change the Current Node" 
(yet another thing I would never have thought of (!))

>> is it reasonable to assert that one can do without the use of 
'xsl:for-each select=', and can achieve everything one needs within 
the 'select=' attribute of 'xsl:variable' and 'xsl:apply-templates' ?

If this assertion is (reasonably) the case, then I guess I can
expect to be able to avoid creating variables by way of RTF, and can
them instead the preferred way of 'xsl:variable select=' statements.

Thanks for any light anyone can shed, etc.

Best regards,
William Reilly
Boston, Massachusetts U.S.A.
++++ /End of posting ++++++++++++++++++++++++++++++++++++++++++++++++++

 XSL-List info and archive:

Current Thread