Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 9th, 2010, 06:02 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default xsl propagation

Hi,

I'm in beginner in xsl. i want to propagate some text(red highlighted text) in between paragraph 1 and paragraph 2. Kindly look at below our sample text.

<HR>
<SL>[]INTERFERENCE[]</SL>
<DE>[]Anti-union[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>

<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]Excluding[]</DE>
<OR>&amp;rtrif; 50.691</OR>

<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]solicitation rule[]</DE>
<OR>&amp;rtrif; 50.181</OR>

<HR-CP>Paragarph 1</HR-CP>
<SL>[]INTERFERENCE 10(c)[]</SL>
<DE>[]Surveillance &mdash; Remedy[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>

<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
</HR>

Excepted output like:

<HR>
<SL>[]INTERFERENCE[]</SL>
<DE>[]Anti-union[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>

<HR-CP>Paragarph 1</HR-CP>
<DE>[]Anti-union[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>

<HR-CP>Paragarph 2</HR-CP>
<DE>[]Excluding[]</DE>
<OR>&amp;rtrif; 50.691</OR>

<HR-CP>Paragarph 1</HR-CP>
<DE>[]Excluding[]</DE>
<OR>&amp;rtrif; 50.691</OR>

<HR-CP>Paragarph 2</HR-CP>
<DE>[]solicitation rule[]</DE>
<OR>&amp;rtrif; 50.181</OR>

<HR-CP>Paragarph 1</HR-CP>
<SL>[]INTERFERENCE 10(c)[]</SL>
<DE>[]Surveillance &mdash; Remedy[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>

<HR-CP>Paragarph 1</HR-CP>
<DE>[]Surveillance &mdash; Remedy[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>

<HR-CP>Paragarph 2</HR-CP>
</HR>

If single paragarph come that instance no need to propagate. more than one paragraph present that time propagate for pervious instance of <DE> and <OR>. Kindly refer above our except output. Kindly give for this occurence xlt code for me.
 
Old December 9th, 2010, 06:54 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It's quite difficult to work out exactly what your transformation rules are. I'm afraid sentences like this don't make much sense:

If single paragarph come that instance no need to propagate. more than one paragraph present that time propagate for pervious instance of <DE> and <OR>.

Judging from your sample, if a "Paragraph 1" is empty, you want to add a copy of whatever preceded that "Paragraph 1" header, since the previous paragraph header. Is that a reasonable description?

This transformation is difficult because the true structure of your data is not explicit in the XML. In fact, it's not even clear to me what the true structure is: it's not helped by the use of meaningless tags like DE and OR. But I would start by building a richer hierarchy of elements in which an HR-CP header and its following DE and OR elements are grouped under some parent element. To build that in XSLT 2.0, you will probably want to use <xsl:for-each-group select="*" group-starting-with="HR-CP">. Having created such a hierarchy, it's relatively easy to process it using template rules, where the template rule that matches an empty paragraph-1 copies the content of the preceding-sibling paragraph-1. As a final step, you can then flatten the structure again to a one-dimensional sequence of elements.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old December 9th, 2010, 08:42 AM
Authorized User
 
Join Date: Nov 2010
Posts: 50
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi,

Sorry for the unclear msg.

The root tag here is <HR>. HR tag inside <DE>, <OR> and <HR-CP> present. when morethan one <HR-CP> tag present, the previous <DE> and <OR> propagate to in between <HR-CP>.
<HR>
<SL>[]INTERFERENCE[]</SL>
<DE>[]Descriptor 1[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>
<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]Descriptor 2[]</DE>
<OR>&amp;rtrif; 50.691</OR>
<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]Descriptor 3[]</DE>
<OR>&amp;rtrif; 50.181</OR>
<HR-CP>Paragarph 1</HR-CP>
<SL>[]INTERFERENCE 10(c)[]</SL>
<DE>[]Descriptor 4[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>
<HR-CP>Paragarph 1</HR-CP>
<HR-CP>Paragarph 2</HR-CP>
</HR>

Excepted output.

<HR>
<SL>[]INTERFERENCE[]</SL>
<DE>[]Descriptor 1[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>
<HR-CP>Paragarph 1</HR-CP>
<DE>[]Descriptor 1[]</DE>
<OR>&amp;rtrif; 50.709</OR>
<OR>&amp;rtrif; 50.54</OR>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]Descriptor 2[]</DE>
<OR>&amp;rtrif; 50.691</OR>
<HR-CP>Paragarph 1</HR-CP>
<DE>[]Descriptor 2[]</DE>
<OR>&amp;rtrif; 50.691</OR>
<HR-CP>Paragarph 2</HR-CP>
<DE>[]Descriptor 3[]</DE>
<OR>&amp;rtrif; 50.181</OR>
<HR-CP>Paragarph 1</HR-CP>
<SL>[]INTERFERENCE 10(c)[]</SL>
<DE>[]Descriptor 4[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>
<HR-CP>Paragarph 1</HR-CP>
<DE>[]Descriptor 4[]</DE>
<OR>&amp;rtrif; 50.271</OR>
<OR>&amp;rtrif; 56.109</OR>
<HR-CP>Paragarph 2</HR-CP>
</HR>

Kindly to the needful.





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:function pass param to attribute of xsl:instruction bonekrusher XSLT 4 March 31st, 2009 09:06 AM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
DNS propagation time madhukp Classic ASP Basics 6 July 8th, 2004 12:52 AM
ODBC and Viruses Propagation - Is it possible rooroo Access 0 December 9th, 2003 05:04 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.