Automic Workload Automation

Expand all | Collapse all

Working with XML objects

  • 1.  Working with XML objects

    Posted May 19, 2017 09:12 AM

    I’m trying to understand how best to store, read, and modify arbitrary XML in UC4 objects. I see a couple of ways of doing this:

    1. XML VARA objects
    2. Structured documentation tabs

    1. XML VARA objects

    There are a few scripting commands that can be used to work with XML VARA objects:

    GET_VAR

    Using GET_VAR, one can retrieve either the whole XML content for a particular VARA key, or use an Xpath query to retrieve just part of the XML.

    :PUT_VAR

    When using :PUT_VAR, one cannot write or modify just part of the XML. One must replace the whole thing or nothing.

    PREP_PROCESS_VAR_XML

    Using PREP_PROCESS_VAR_XML, one can create a data sequence based on an XPath query.

    2. Structured documentation tabs

    The AE scripting language includes many functions for working with structured documentation tabs, including:

    Using these scripting functions, one can easily manipulate individual parts of the XML.

    The functions for working with structured documentation are quite flexible. Is there any way to get similarly fine-grained control over XML stored in XML VARA objects?



  • 2.  Working with XML objects

    Posted Jun 09, 2017 03:03 PM
    So far, crickets. Does anyone actually use these XML features? I get the idea that they’re used by Automic’s own objects; but do actual customers use them?


  • 3.  Re: Working with XML objects

    Posted Apr 30, 2018 10:18 AM

    Dear Michael,

    I once tried to read an xml file created out of a PDF file. There were a lot of style-attributes in the tags, so my Oracle-Database could not store the original xml-file.

    Since I just wanted to get some Table-Data out of that file, I wrote a little bash script to get rid of all unnecessary lines and attributes:

    #!/bin/bash
    set -x

    if [ "$1" != '' ]; then
        PDatei=$1
    else
      # Parameter fehlt
      echo "Parameter fehlt: Dateiname der zu vereinfachenden xml-Datei (ohne .xml)" && exit 1
    fi

    egrep -i "<Data|<Cell|<Row|</Data|</Cell|</Row" $PDatei.xml > $PDatei-1.xml || exit 2
    sed 's/<\([A-Za-z]*\) [^\/>]*\(\/>\|>\)/<\1\2/g' $PDatei-1.xml > $PDatei-erg.xml || exit 3

    Line 11 cuts out only the lines with data-, cell- or row-tags. This works only, if the data in the file contain no linefeed.

    Line 12 cuts out all attributes in the tags.

    After cleaning out the file with this script, I was able to load the xml into an XML-VARA.

     

    I do not use that any more though, since I was able to get the original data via csv - this is so much easier and reliable to process!

     

    Regards, Nicole

     

    PS. I forgot the <Table>-tag in the script. I used that, too, for surrounding the rows.



  • 4.  Working with XML objects

    Posted Jun 09, 2017 04:27 PM
    We are using XML_OPEN and XML_GET_NODE_TEXT to retrieve documentation for appending to the body of our failure alert emails.


  • 5.  Re: Working with XML objects

    Posted Apr 30, 2018 12:42 PM

    The SAP Application logs are also in XML. Can use the XML commands to parse the application log that is returned in SAP jobs.

     

    Docu: Report types 



  • 6.  Re: Working with XML objects

    Posted Aug 23, 2018 08:56 AM

    I recently discovered that it’s possible to use CREATE_OBJECT to create XML VARAs. This makes the following workflow possible:

    1. Use CREATE_OBJECT to create an XML VARA object.
    2. Use :PUT_VAR to write XML content to the XML VARA object.
    3. Use GET_VAR to read one part of the XML VARA object.
    4. Use PREP_PROCESS_VAR_XML and GET_PROCESS_LINE to read multiple parts of the XML VARA object.

     

    #xml #automationenginescript #aescripting #automationengine #caautomicautomationengine #caautomicworkloadautomation



  • 7.  Re: Working with XML objects

    Posted Aug 23, 2018 09:26 AM

    I thought this approach might also work:

    1. Use PREP_PROCESS_VAR_XML to create a data sequence connected to an XML VARA object
    2. Use XML_PROCESS_TO_DOM to create a document object model (DOM) of the XML document, based on the data sequence.
    3. Use the various Script Functions for XML Elements* to work directly with the XML VARA, via the DOM.
    4. Somehow, save any changes to the XML VARA.

     

    * These script functions are:

     

    If this is supposed to work, I haven’t figured it out yet. The documentation page for e XML_PROCESS_TO_DOM includes an example using PREP_PROCESS_FILE to create a data sequence from an XML file stored on the file system. However, it does not include an example using PREP_PROCESS_VAR_XML.



  • 8.  Re: Working with XML objects

    Posted Aug 23, 2018 10:13 AM

    Ok, I figured it out. Here is how to use the XML handling functions with an XML VARA:

    1. Use GET_VAR to read all or part of an XML VARA object into a variable as a string.
    2. Use XML_OPEN with the STRING parameter to convert the string into an XML DOM.
    3. Use the Script Functions for XML Elements to work directly with the XML DOM, optionally making changes.
    4. Use XML_TO_STRING to convert the XML DOM back to a string.
    5. Use XML_CLOSE to close the XML DOM.
    6. Use :PUT_VAR to write the XML string back the XML VARA object.


  • 9.  Re: Working with XML objects

    Posted Aug 23, 2018 10:15 AM

    I discovered a limitation of this approach. At least on my system, the XML_OPEN operation fails if the XML content to be loaded exceeds a certain size.

    8/23/2018 3:46:50 PM -  U00020331 Runtime error in object 'UC0.XML_TEST-1.SCRI', line '00003': U00003590 UCUDB - DB error: 'OCIStmtFetch', 'ERROR   ', '', 'ORA-19011: Character string buffer too small'

    Both XML VARAs and script variables are supposed to be able to store data of arbitrary length, so this might be a bug.



  • 10.  Re: Working with XML objects

    Posted Aug 31, 2018 11:13 AM

    I reported the ORA-19011 problem with XML_OPEN to CA.

     

    Here’s my guess about what’s going on:

    1. XML VARA information is stored in the OVW table in column OVW_ValueX. The data are stored as CLOBs in Oracle.

    2. The AE’s XML_OPEN function uses SQL that implicitly or explicitly converts the CLOB to VARCHAR2.

    3. The error occurs when the size of the CLOB exceeds 4000 characters (the maximum size of VARCHAR2).

    I passed along this information in the ticket. I’ll post an update when I know more.



  • 11.  Re: Working with XML objects

    Posted Nov 28, 2018 05:02 AM

    CA has acknowledged that this is a bug. The fix is currently planned for release in 12.2.2 and 12.3.0. I don't know the KB article number yet, but our case number for this is 01180988.



  • 12.  Re: Working with XML objects

    Posted Feb 15, 2019 09:24 AM

    CA published a new KB article about this:

    KB000121626 – XML_OPEN -> 'ORA-19011: Character string buffer too small' with large XML VARA entries

     

    Here’s an excerpt:

    This is a bug which shall be corrected in the following releases:

    AE 12.2.2 scheduled for 11.02.2019 
    AE 12.3.0 scheduled for 28.02.2019 

    The ship date of 12.2.2 has slipped a bit, and I gather 12.3 will also be delayed.



  • 13.  Re: Working with XML objects

    Posted Dec 04, 2018 11:41 AM

    I took what I learned here and incorporated it into a new document:

    Working with XML in the Automation Engine 



  • 14.  RE: Re: Working with XML objects

    Posted Sep 17, 2020 08:39 PM
    Hi Michael,

    I am getting the below XML response. I need to get the highlighted value Pid 173532 into the selected variable. I need Expression (Below automic screen) syntax to get the exact value 173532 from the XML. Can you please help? 

    Also we have three types Xpath, XQury, Groovy. Which one would be optimal solution and syntax for each category?


    2020-09-17 14:33:21             SOAP Response
    2020-09-17 14:33:21             Response-Code: 200
    2020-09-17 14:33:21             Content-Type: text/xml;charset=utf-8
    2020-09-17 14:33:21             Transfer-Encoding: chunked
    2020-09-17 14:33:21             Date: Thu, 17 Sep 2020 21:33:20 GMT
    2020-09-17 14:33:21             Set-Cookie: 96b6db70e130181d48cd95ed13fde9aa=110fd272f386476842dbd7d1853be6d1; path=/; HttpOnly; Secure
    2020-09-17 14:33:21             Payload: <tns:Envelope xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/">
    2020-09-17 14:33:21                <tns:Header>
    2020-09-17 14:33:21                   <gwsoap:traceability_id xmlns:gwsoap="http://guidewire.com/ws/soapheaders">?</gwsoap:traceability_id>
    2020-09-17 14:33:21                </tns:Header>
    2020-09-17 14:33:21                <tns:Body>
    2020-09-17 14:33:21                   <startBatchProcessResponse xmlns="http://guidewire.com/ab/ws/gw/webservice/ab/ab1000/MaintenanceToolsAPI">
    2020-09-17 14:33:21                      <return xmlns:pogo="http://guidewire.com/gw/api/tools">
    2020-09-17 14:33:21                         <pogo:Pid>173532</pogo:Pid>
    2020-09-17 14:33:21                      </return>
    2020-09-17 14:33:21                   </startBatchProcessResponse>
    2020-09-17 14:33:21                </tns:Body>
    2020-09-17 14:33:21             </tns:Envelope>
    2020-09-17 14:33:21             --------------------------------------
    2020-09-17 14:33:21             Starting XQuery response script execution.
    2020-09-17 14:33:21             Response script execution done.