xsl-list
[Top] [All Lists]

Re: [xsl] Manipulating elements depending on the existence of sub-elements

2008-03-11 12:39:48
Nice! The "following-sibling" function was exactly what I was looking
for, thank you very much Michael. My poorly parsed data now has it's
rightfully owned unique id information.

My only remaining issue is that the position() count is inaccurate for
the problematic "Item" (as it is contained in 2 "Item" elements rather
than one, so the count will be 1, 2, 3, 1, 2, 3 instead of 1, 2, 3, 4,
5, 6) but I'm guessing there isn't much I can do about this in XSL?
(since position()'s value *is* technically accurate, and I'm actually
trying to manipulate it)

If nothing can be done about it in XSL I can probably add a count in
.net prior to bulk loading.

Adil



On Tue, Mar 11, 2008 at 3:13 PM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
wrote:
So my XSL question is: am I able to check for the existence
of a "UniqueInfo" element within an "Item" element, and if
one does not exist, use the UniqueInfo element that the next
"Item" contains?

Try select="(UniqueInfo | following-sibling::Item[1]/UniqueInfo)[1]

for example, in a variable:

<xsl:variable name="uniqueInfo"
 select="(UniqueInfo | following-sibling::Item[1]/UniqueInfo)[1]"/>

This relies on the fact that the result of a union (|) is always in document
order, and "[1]" will therefore select whichever comes first: the UniqueInfo
child of this item, or the UniqueInfo child of the next item.

Michael Kay
http://www.saxonica.com/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--