Absent Member.. dsalkin Absent Member..
Absent Member..
1240 views

Writing XML files

Jump to solution

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

Labels (1)
Tags (1)
0 Likes
1 Solution

Accepted Solutions
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

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/JsonSaxAdapter.java

 

 

0 Likes
6 Replies
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

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/JsonSaxAdapter.java

 

 

0 Likes
Absent Member.. dsalkin Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

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

0 Likes
Absent Member.. ntt00015 Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

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.

0 Likes
Absent Member.. warrenf Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

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.
Absent Member.. warrenf Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution

Attached is my example flow.

Absent Member.. dsalkin Absent Member..
Absent Member..

Re: Writing XML files

Jump to solution
Thanks Warren
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.