[XSL-LIST Mailing List Archive Home]
[Reply To This Message]
Re: XSL pattern needed for begin/end elements
Subject: Re: XSL pattern needed for begin/end elements|
From: Mike Trotman <mike.trotman@xxxxxxxxxxxxx>
Date: Wed, 07 Jul 2004 19:25:38 +0100
If the begin and end elements are siblings at the same level then the
problem is tractable and probably not too difficult to solve.
However if they can occur at different levels then this means that one
of them is enclosed inside an element that excludes the other (I think).
Can you give any example of a case where the begin and end elements are
not siblings at the same level?
I ask because:
a) I can't picture how this would make sense given the information that
you require them to contain
b) If one of them does occur inside an element that excludes the other
- what would you want to to with the excluded part of this elements
content / tree?
- If you start closing all the parent elements etc (and opening them
again to match the orphaned end tags)
then you are destroying the structure and meaning of the XML data
which XSLT is designed to help preserve.
I.e. if they are not siblings at the same level then the XML data
'structure' is totally inappropriate for XSLT
and the 1st thing you should do is process it using something else.
I have documents like this - and I process them by walking the DOM tree
and maintaining a separate STACK of whatever I consider my current
context to be.
(I am doing this to detect overlap between different document layers
marked in exactly the way you describe.)
Tracy Atteberry wrote:
I'm looking for an XSL pattern to solve the problem of going from XML
that has separate begin and end elements to one that does not.
Please, please note that I do not control either the source or target
XML formats. If I did, this would be much easier.
Source XML snip:
<hyperlink_begin id=3D"111" end=3D"222">
<locator_url protocol=3D"http" host_name=3D"www.sf.net"/>
<hyperlink_end id=3D"222" begin=3D"111"/>
Target XML example:
In my case I can assume that associated begin and end hyperlink tags
will occur as siblings -- though generally this is not the case and in
fact, this is the reason the begin and end tags are unique elements.
I have a template that /almost/ works so feel free to let me know why it
fails OR suggest a completely different solution.
Current XSL template snip:
<xsl:variable name=3D"endID" select=3D"@end"/>
<xsl:apply-templates select=3D"(following-sibling::*) except
This produces the correct hyperlink but the template for text_run
elements gets called twice this way -- once inside the hyperlink, then
again as templates continue to be applied.
Any help would be greatly appreciated. Thanks!
PS. I'm using Saxon 8
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@xxxxxxxxxxxxxxxxxxxxxx>
8 Eileen Road
London SE25 5EJ
UK Co. Reg: 4383635
VAT Reg.: 798 7531 60
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format