[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSL pattern needed for begin/end elements

Subject: Re: XSL pattern needed for begin/end elements
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Wed, 07 Jul 2004 11:05:15 -0600
templates for 3d m
Ive been caught on that one as well Pieter :) At first glance it seems obvious... but its just a difference in encoding and is perfectly fine from the standpoint of the parser and transformer... If it makes you feel any better the time I posted a similar response was found and called out by Michael Kay... Although he didnt laugh at me that hard (figuratively speaking of course :) it was still Michael Kay so my cheeks were a bit red with embarrasment there for a while...

Tracy, let me look deeper into this and Ill respond back in a sec and see if I can help you out a bit...

<M:D/>



Pieter Reint Siegers Kort wrote:
Hi Tracy,

to start, your XML (both source and target) is not well-formed...
id=3D"111", etc. - did some nasty character get mixed in perhaps?

We might want to guess what's your real XML is like, but we better await
your answer.

Cheers,
<prs/>

-----Original Message-----
From: Tracy Atteberry [mailto:Tracy.Atteberry@xxxxxxxxxxxx] Sent: Wednesday, July 07, 2004 11:15 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: XSL pattern needed for begin/end elements


Hi all,

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:

<doc>
  <hyperlink_begin id=3D"111" end=3D"222">
    <locator_url protocol=3D"http" host_name=3D"www.sf.net"/>
  </hyperlink_begin>
  <text_run>Click</text_run>
  <text_run emphasis=3D"bold">here.</text_run>
  <hyperlink_end id=3D"222" begin=3D"111"/> </doc>

Target XML example:

<cod>
  <HyperLink xlink:href=3D"http://www.sf.net">
    Click <b>here.</b>
  </HyperLink>
</cod>

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:template match=3D"//hyperlink_begin">
    <xsl:variable name=3D"linkUrl">
        <xsl:value-of select=3D"locator_url/@protocol"/>
        <xsl:text>://</xsl:text>
        <xsl:value-of select=3D"locator_url/@host_name"/>
    </xsl:variable>
    <xsl:variable name=3D"endID" select=3D"@end"/>
    <xsl:element name=3D"HyperLink">
        <xsl:attribute name=3D"xlink:href"><xsl:value-of
select=3D"$linkUrl"/></xsl:attribute>
        <xsl:apply-templates select=3D"(following-sibling::*) except
(following-sibling::hyperlink_end[@id=3D$endID]/following-sibling::*)"/>
    </xsl:element>
</xsl:template>

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!

Tracy Atteberry

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>
--+--

--+------------------------------------------------------------------
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>
--+--


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.