Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 9th, 2010, 06:02 AM
Authorized User
Points: 234, Level: 4
Points: 234, Level: 4 Points: 234, Level: 4 Points: 234, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
  #2 (permalink)  
Old December 9th, 2010, 06:54 AM
mhkay's Avatar
Wrox Author
Points: 18,438, Level: 59
Points: 18,438, Level: 59 Points: 18,438, Level: 59 Points: 18,438, Level: 59
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,954
Thanks: 0
Thanked 290 Times in 285 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
Reply With Quote
  #3 (permalink)  
Old December 9th, 2010, 08:42 AM
Authorized User
Points: 234, Level: 4
Points: 234, Level: 4 Points: 234, Level: 4 Points: 234, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:function pass param to attribute of xsl:instruction bonekrusher XSLT 4 March 31st, 2009 10:06 AM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 11:32 PM
DNS propagation time madhukp Classic ASP Basics 6 July 8th, 2004 01: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 08:30 AM



All times are GMT -4. The time now is 02:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.