Subject: RE: [xsl] XSL pattern needed for begin/end elements From: "Tracy Atteberry" <Tracy.Atteberry@xxxxxxxxxxxx> Date: Wed, 7 Jul 2004 12:05:29 -0500 |
Sorry about that. Looks like my client was inserting '3D's after every '='. Let's try again... --------------- 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="111" end="222"> <locator_url protocol="http" host_name="www.sf.net"/> </hyperlink_begin> <text_run>Click</text_run> <text_run emphasis="bold">here.</text_run> <hyperlink_end id="222" begin="111"/> </doc> Target XML example: <cod> <HyperLink xlink:href="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="//hyperlink_begin"> <xsl:variable name="linkUrl"> <xsl:value-of select="locator_url/@protocol"/> <xsl:text>://</xsl:text> <xsl:value-of select="locator_url/@host_name"/> </xsl:variable> <xsl:variable name="endID" select="@end"/> <xsl:element name="HyperLink"> <xsl:attribute name="xlink:href"><xsl:value-of select="$linkUrl"/></xsl:attribute> <xsl:apply-templates select="(following-sibling::*) except (following-sibling::hyperlink_end[@id=$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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XSL pattern needed for be, M. David Peterson | Thread | Re: [xsl] XSL pattern needed for be, M. David Peterson |
Re: [xsl] XSL pattern needed for be, M. David Peterson | Date | Re: [xsl] using preceding-sibling t, Vasu Chakkera |
Month |