473,385 Members | 1,940 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

reverse element

samueln12
Hai all,

I need to reverse the following element:
Eg:
<link rid="www.goldcopd.com"><comment style="inline">www.goldcopd.com</comment></link>

Should be:
<comment style="inline"><link rid="www.goldcopd.com">www.goldcopd.com</link></comment>

Can any one help me out

Thanks
Sam
Feb 3 '09 #1
8 2128
Dormilich
8,658 Expert Mod 8TB
that depends on the circumstances. do you use XSLT or a script language, is this a part of a XML, are you only interested in this part of the XML, ...

regards
Feb 3 '09 #2
Can you help me out how to do with XSLT
Feb 3 '09 #3
Dormilich
8,658 Expert Mod 8TB
sure, what do you have so far? (there are some ways to accomplish the task, but they all depend on the rest of the XML and XSLT)
Feb 3 '09 #4
I am quite familer in XSLT and Perl.

But i don't what to go for Perl. I want to use XSLT as the transformer for this.

Case 1:
Expand|Select|Wrap|Line Numbers
  1. <comment>Available at: </comment><ext-link ext-link-type="uri" xlink:href="www.goldcopd.com"><comment>www.goldcopd.com</comment></ext-link>
i am able to get the text
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="comment[not(parent::ext-link)]">
  2.     <comment><xsl:apply-templates/></comment>
  3. </xsl:template>
Case 2:
Expand|Select|Wrap|Line Numbers
  1. <comment>Available at: </comment><ext-link ext-link-type="uri" xlink:href="www.goldcopd.com"><comment>www.goldcopd.com</comment></ext-link>
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="comment[(parent::ext-link)]">
  2. ...
  3. </xsl:template>
Please guide me how to write this.

Thanks
Sam
Feb 3 '09 #5
Dormilich
8,658 Expert Mod 8TB
do you want to switch the tags as they are, or do some adjustments too?
Feb 3 '09 #6
<comment>Available at: </comment><ext-link ext-link-type="uri" xlink:href="www.goldcopd.com"><comment>www.goldcop d.com</comment></ext-link>

The XSLT transformation should work for the above occurance. I don't want to lose data. Because this is for STM books and journals. I want to retain the attribute in their element.

<comment>Available at: </comment><ext-link ext-link-type="uri" xlink:href="www.goldcopd.com">See <comment>www.goldcopd.com</comment></ext-link>

For this occurance retain the XML as is..

Thank you for your help
Sam
Feb 3 '09 #7
jkmyoung
2,057 Expert 2GB
So you are only changing the <ext-link> nodes that don't have a direct text() node? Like :?
Expand|Select|Wrap|Line Numbers
  1. <xsl:template match="ext-link[not(text())][comment]">
  2.   <comment>
  3.     <xsl:copy-of select="comment/@*"/>
  4.     <xsl:copy>
  5.       <xsl:copy-of select="@*"/>
  6.       <xsl:value-of select="comment"/>
  7.     </xsl:copy>
  8.   </comment>
  9. </xsl:template>
  10.  
Or should the <xsl:value-of select="comment"/> be
like <xsl:apply-templates select="comment" mode="inside"/>?
Feb 3 '09 #8
Many Thanks its working perfectly. Once again thank you very much
Feb 4 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

35
by: Raymond Hettinger | last post by:
Here is a discussion draft of a potential PEP. The ideas grew out of the discussion on pep-284. Comments are invited. Dart throwing is optional. Raymond Hettinger ...
19
by: John Keeling | last post by:
Dear all, I tried the test program below. My interest is to examine timing differences between insert vs. append & reverse for a list. My results on my XP Python 2.3.4 are as follows:...
8
by: Jim Langston | last post by:
I have a class I designed that stores text chat in a std::vector<sd::string>. This class has a few methods to retrieve these strings to be displayed on the screen. void ResetRead( bool Reverse,...
7
by: JavaScriptRocks | last post by:
I've been trying to imitate / reverse engineer the add attachment feature in gmail composer. I managed to do it to say about 80% but its giving me trouble in IE on WinXP-Sp2. I am using PHP to do...
19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
2
by: nafri | last post by:
i have a colleciton that i need to reverse. Array has a reverse method. Is their any direct way to transfer the items in the collection to an array or arraylist, reverse the array and transfer back...
22
by: delraydog | last post by:
It's quite simple to walk to the DOM tree going forward however I can't figure out a nice clean way to walk the DOM tree in reverse. Checking previousSibling is not sufficient as the...
3
by: thrill5 | last post by:
I have an xml document such as: <device> <element>first</element> <element>second</element> </device> I am using this as the source for an xslt transform that goes like <xsl:for-each...
15
by: Boltar | last post by:
Hi I'm going through an STL list container using a reverse iterator but it seems the erase() method only accepts ordinary iterators. Is there a similar method that will accept reverse iterators...
1
by: Chris Rebert | last post by:
On Thu, Oct 2, 2008 at 8:07 PM, David Di Biase <dave.dibiase@gmail.comwrote: Rather than defining a comparison function here (which is less efficient), you can use the 'key' argument, which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.