• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Eliminate duplicates in XML to XML conversion

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an XML which I need to convert to another XML.

Every element in the original XML needs to be converted to some other element.

Say,

element <book> needs to be converted to <ebook>,
<content> needs to be converted to <econtent> and so on...

Example, Original XML is

correponding converted XML should be


I have written an XSL for this which works fine

But there is one problem I am facing.
If there are consecutive elements with the same name which are empty then only one element should be displayed.
Say, original XML is

converted XML should be


Please help...
[ February 05, 2007: Message edited by: Thomas Greene ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That means, I think, that if you have a <chapter> element that has no children and whose immediate following sibling is also a <chapter> element that has no children, then you want to produce nothing. So you want an expression that describes that situation. Something like this:That probably isn't quite right but hopefully it can be cleaned up to work.
 
Thomas Greene
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying.

Originally posted by Paul Clapham:
T then you want to produce nothing.



I want to produce only one element in that case.
Example,
<chapter />
<chapter />

will be converted to

<chapter />
 
Thomas Greene
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Clapham:
That means, I think, that if you have a <chapter> element that has no children and whose immediate following sibling is also a <chapter> element that has no children, then you want to produce nothing. So you want an expression that describes that situation. Something like this:That probably isn't quite right but hopefully it can be cleaned up to work.



Thanks

Using the above code, if there are text values inside elements,
like

<chapter>2. Chapter 1</chapter>
<chapter>3. Chapter 2</chapter>
<chapter>4. Chapter 3</chapter>

even this is getting converted to

<chapter>4. Chapter 3</chapter>

I want the process to happen if there are only EMPTY elements(with no child elements, no text value and no attribute)
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay. So "count(*)" isn't quite right. Your next step is to find out what exactly that does and how to change it so it counts all children.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic