Operations Orchestration Support and News Forum
Showing results for 
Search instead for 
Do you mean 

Writing XML files

SOLVED
Go to Solution
Highlighted
Advisor

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

1 ACCEPTED SOLUTIONS
Trusted Contributor

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...

 

 

6 REPLIES
Trusted Contributor

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...

 

 

Advisor

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

Trusted Contributor

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.

Trusted Contributor

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.
Trusted Contributor

Re: Writing XML files

Attached is my example flow.

Advisor

Re: Writing XML files

Thanks Warren