Re: Writing XML files (190 Views)
Reply
Advisor
dsalkin
Posts: 30
Registered: ‎06-07-2012
Message 1 of 7 (364 Views)
Accepted Solution

Writing XML files

Does anyone know how to write XML files in OO (but not using un-structured File System operations). I have specifically attempted to use groovy's MarkupBuilder but although it imports groovy.xml it cannot import groovy.xml.MarkupBuilder.

 

Any suggestions?

 

David Salkin
HP Software-as-a-Service

Please use plain text.
Trusted Contributor
ntt00015
Posts: 91
Registered: ‎09-18-2011
Message 2 of 7 (351 Views)

Re: Writing XML files

[ Edited ]

Hi,

 

As far as I know there is no built in solution in OO.

 

I've never tried something like that but just a suggestion.  Have you tried to use JSON format? You can constitute your xml data with JSON operations and after you can change it into XML form using XSLT transform operation. There are some solutions about transforming JSON to XML.

 

Best Regards.

 

Sample conversion code: https://github.com/lukas-krecan/json2xml/blob/master/src/main/java/net/javacrumbs/json2xml/JsonSaxAd...

 

 

Please use plain text.
Advisor
dsalkin
Posts: 30
Registered: ‎06-07-2012
Message 3 of 7 (333 Views)

Re: Writing XML files

Thanks for the suggestion and link which I may pick up on in the future. We actually ran a Powershell operation to do it:

 

$xml = New-Object XML
$xml.Load("c:\tmp\server.xml")
$xml.Server.Service.Connector | Where-Object { $_.protocol -eq 'HTTP/1.1' } | ForEach-Object { $_.port = '8082' }
$xml.Save("c:\tmp\server.xml")

 

Regards,

 

David

Please use plain text.
Trusted Contributor
ntt00015
Posts: 91
Registered: ‎09-18-2011
Message 4 of 7 (318 Views)

Re: Writing XML files

You are right, using Powershell or Perl script is the fastest&easiest solution for your problem. If I don't misremember there must be a Enhancement Request about this issue.

Please use plain text.
Trusted Contributor
warrenf
Posts: 200
Registered: ‎05-09-2007
Message 5 of 7 (193 Views)

Re: Writing XML files

So I had a very similar requirement to yours and managed to get a script that imports MarkupBuilder to run.

All I had to do was replace the groovy*.jar files in my RAS server's Groovy path (<OO-Install-Path>\RAS\Java\Default\repository\lib\Groovy) with the following files from my local Groovy installation:

 

  1. groovy-2.0.5.jar
  2. groovy-jsr223-2.0.5.jar
  3. groovy-xml-2.0.5.jar

(It is the third file that is the missing link)

Restarted my RAS service and then my script ran successfully.

 

Good Part/s:

  • At least there is an alternative to Powershell for this now.
  • This method can be used to exploit other libraries from Groovy not included in the standard distribution that ships with the OO Content Pack.

Bad Part:

  • Updating all of the RAS server may be a chore.
Please use plain text.
Trusted Contributor
warrenf
Posts: 200
Registered: ‎05-09-2007
Message 6 of 7 (190 Views)

Re: Writing XML files

Attached is my example flow.

Please use plain text.
Advisor
dsalkin
Posts: 30
Registered: ‎06-07-2012
Message 7 of 7 (173 Views)

Re: Writing XML files

Thanks Warren
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation