• 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

Need XSLT logic

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have XML like this ..the format is not fixed for this XML...there can any number of empty elements

<entries>
<entry no="11">Some text</entry >
<entry no="12"></entry >
<entry no="13">IPAddress1..............123456</entry >
<entry no="14">IPAddress2..............453456</entry >
<entry no="15">IPAddress3..............77656</entry >
<entry no="16">Some text</entry >
<entry no="17">IPAddress1..............123456</entry>
<entry no="18">IPAddress2..............67856</entry >
<entry no="19">IPAddress3..............699456</entry >
<entry no="20"></entry >
<entry no="21"></entry >
<entry no="22"></entry >
<entry no="23"></entry>
<entry no="24">IPAddress1..............123456</entry >
<entry no="25">IPAddress2..............443456</entry >
<entry no="26">IPAddress3..............456789</entry>
</entries>



required output XML

<Addresses>

<IPAdresses>
<IP1></IP1>
<IP2></IP2>
<IP3></IP3>
</><IPAddress>
<IPAdresses>
<IP1></IP1>
<IP2></IP2>
<IP3></IP3>
</><IPAddress>
</Addresses>

Can you please give me some idea for XSLT logic? I am novice to this.....

How can i iterate over same element?
 
Bk Jacky
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any help me plzzzz?
 
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
I looked at your post when it originally appeared. I couldn't figure out what the relationship between the proposed output and the posted input was. There was data in the output which wasn't in the input, and you didn't say anything about the rules for generating that output.

The whole point of XSLT is that it implements those rules. So your first step is to decide what they are. If you want somebody to explain how to write XSLT implementing your rules, it would be polite to say what they are instead of making people guess. Looks like nobody was interested in guessing.
 
Bk Jacky
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul Clapham,

XSLT should output IPAddress only from the Input doc. It should create new element <IPAdress> for each IPAdress

We can group max three IP address under <Address> element.After that we have to create new <Address> element.

I think it will clear some picture....

 
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

Bk Jacky wrote:Paul Clapham,

XSLT should output IPAddress only from the Input doc. It should create new element <IPAdress> for each IPAdress

We can group max three IP address under <Address> element.After that we have to create new <Address> element.

I think it will clear some picture....



A little more clear. But your original example had elements like <IP1> in the output. That wasn't mentioned in the requirements you just posted. The "IP1" wasn't anywhere in the input document. So I don't understand where that is supposed to come from. And the original example didn't actually have any <IPAdress> elements or any <IPAddress> elements for that matter. Or any <Address> elements -- which is it supposed to be, anyway? So your explanation doesn't explain anything about the example.

Let me also suggest that when you start trying to write this XSLT document you start by ignoring the requirement that you have to have multiple <Address> elements containing at most three, um, whatever it is child elements you're talking about. That's going to be hard to program. (And it's also a peculiar requirement -- I don't see any point in it.)

So I guess my summary is: Find out what the requirements are for this transformation. Get a real-life example that is actually an example of the requirements.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic