Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Groovy XML

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to write a parser that essentially will turn the following.

<Transaction Number="1' Date="102308"/>
and turn it into the following

<Transaction Number="1' Date="102308"></Transaction>

I am assuming I would need to use a NodeBuilder to build the XML again, but am unclear if it would build it in the desired manner.

Does anyone know how to do this? Thanks.
 
Marshal
Posts: 28288
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
They are the same XML so there shouldn't be a requirement to do that. I doubt there are any XML serializers in any language which have that as an option, since the XML recommendation specifically says they are equivalent.
 
Bill Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that this shouldn't be an issue, but the way data rules on the other side are causing the error.

<Transacation/>
<Transaction>
<element1></element1>
<element2></element2>
<element3></element3>
</Transaction>

This is interpreted as 1 transaction even if they are two. APPARENTLY, this is how it should like to reflect as 2 transactions. I agree with you in that it shouldn't make a difference.

We need to change it to:
<Transacation>
</Transaction>
<Transaction>
<element1></element1>
<element2></element2>
<element3></element3>
</Transaction>
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, after doing a simple test (which you could have done too) groovy does indeed spit out the undesired XML. Obviously, this goes without saying, but you should fix the back-end to support standards rather than hacking standards to support something broken.
 
Bill Lee
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't control the back end.
 
Paul Clapham
Marshal
Posts: 28288
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
Then you're going to have to get in contact with the people who do control the back end, so they can fix their broken software.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yea, what Paul said. Assuming that isn't possible you're probably going to have to see if there is a way to modify the behavior of the node builder to achieve what you want. I'm sure there is a way and since it is groovy, it probably isn't too difficult. I just don't personally know how.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic