Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rmcobol XML extensions reading an xml file with a stylesheet

Status
Not open for further replies.

TSTEVENS123

Programmer
May 13, 2021
4
US
I am trying to read a simple xml file that has attributes with a stylesheet, and I need to capture the data in tags that duplicate like AddressLine. For some reason I can't capture the AddressLine data. I am getting all the other data like Zip, State, City, Name just fine, but getting spaces for the AddressLine. Here is an example of my xml file, stylesheet and cobol program:

focus3.xml (XML FILE)

<?xml version="1.0" encoding="UTF-8"?>

<focus-address Zip="78728" State="TX" City="Austin" Name="Micro Focus" Timestamp="10544627">
<mainAddress>

<addressAll AddressLine="8310 North Capital of Tesax Highway"/>

<addressAll AddressLine="Building 1, Suite 155"/>

</mainAddress>

</focus-address>

XML Stylesheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl=""> >
<xsl:eek:utput method="xml" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="focus-address" />
</xsl:template>
<xsl:template match="focus-address">
<Focus-Address>
<xp-TimeStamp><xsl:value-of select="@Timestamp"/></xp-TimeStamp>
<xp-Name><xsl:value-of select="@Name"/></xp-Name>
<xp-City><xsl:value-of select="@City"/></xp-City>
<xp-State><xsl:value-of select="@State"/></xp-State>
<xp-Zip><xsl:value-of select="@Zip"/></xp-Zip>
<Mainaddress>
<xsl:for-each select="focus-address/addressAll/AddressLine">
<Addressall>
<xp-Address-Line><xsl:value-of select="focus-address/addressAll/@AddressLine"/></xp-Address-Line>
</Addressall>
</xsl:for-each>
</Mainaddress>
</Focus-Address>
</xsl:template>
</xsl:stylesheet>

Cobol program:

Data Division.
Working-Storage Section.
01 Focus-Address.
02 xp-TimeStamp Pic 9(8).
02 xp-Name Pic X(64).
02 xp-City Pic X(32).
02 xp-State Pic X(2).
02 xp-Zip Pic 9(5).
02 Mainaddress.
20 Addressall OCCURS 1 TO 2 TIMES
DEPENDING ON Address-Lines.
30 xp-Address-Line Pic X(64).
01 Done Pic X.
01 Address-lines Pic 9.
Copy "../cpy/lixmlall.cpy".

Procedure Division.
A. Display "Example-3 - Illustrate EXPORT FILE & IMPORT FILE"
" with OCCURS DEPENDING".
XML INITIALIZE.
If Not XML-OK Go to Z.

Move 2 to Address-Lines.

Move Spaces to Focus-Address.

XML IMPORT FILE
Focus-Address
"focus3"
"Focus-Address"
"example3.xsl".

If Not XML-OK Go to Z.
Display "focus3.xml imported by XML IMPORT FILE".
Display xp-Name.
Display xp-Address-Line(1).
Display xp-Address-Line(2).
Display xp-City xp-State xp-Zip.
Display xp-TimeStamp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top