This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Rmcobol and XML Extensions

I am using Rmcobol v12 for Linux and we just purchased the xml extensions so I can work with XML files.  I am trying to create an xml file with the attributes inside the main tags, so I am assuming I need to use a external stylesheet on my XML EXPORT statement.  When I do it only prints the first line, and my attributes are blank.  If I don't use the stylesheet then it creates the whole xml file with my data, but the attributes are not in the proper format.  My stylesheet was generated on a website that converts an XML file to XSLT.  If anyone has any ideas, I would very much appreciate it.  I am new to using xml extensions.

xml file generated: (only get the first line)

<?xml version="1.0" encoding="UTF-8"?>
<asap:AccountServicesTransmission xmlns:asap="urn:us:gov:treas:fms:Payment:AccountAuthorization:2.1" CycleDate="" FileNumber="" TestIndicator="" TransmissionTimestamp=""/>

Stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:asap="urn:us:gov:treas:fms:Payment:AccountAuthorization:2.1" xmlns:xsl="">www.w3.org/.../Transform">
<xsl:template match="/">
<asap:AccountServicesTransmission>
<xsl:variable name="cycleDate" select="/asap:AccountServicesTransmission/@CycleDate"/>
<!-- The variable cycleDate can be used for further processing. -->


<xsl:attribute name="CycleDate"><xsl:value-of select="$cycleDate"/></xsl:attribute>
<xsl:attribute name="FileNumber"><xsl:value-of select="/asap:AccountServicesTransmission/@FileNumber"/></xsl:attribute>
<xsl:attribute name="TestIndicator"><xsl:value-of select="/asap:AccountServicesTransmission/@TestIndicator"/></xsl:attribute>
<xsl:attribute name="TransmissionTimestamp"><xsl:value-of select="/asap:AccountServicesTransmission/@TransmissionTimestamp"/></xsl:attribute>
<asap:CreateAuthorizationRequest>
<xsl:variable name="effectiveDate" select="/asap:AccountServicesTransmission/asap:CreateAuthorizationRequest/@EffectiveDate"/>
<!-- The variable effectiveDate can be used for further processing. -->


<xsl:attribute name="EffectiveDate"><xsl:value-of select="$effectiveDate"/></xsl:attribute>
<xsl:for-each select="/asap:AccountServicesTransmission/asap:CreateAuthorizationRequest/asap:AuthorizationRequest">
<asap:AuthorizationRequest>
<xsl:variable name="accountIdentifier" select="./@AccountIdentifier"/>
<!-- The variable accountIdentifier can be used for further processing. -->


<xsl:attribute name="AccountIdentifier"><xsl:value-of select="$accountIdentifier"/></xsl:attribute>
<xsl:attribute name="Amount"><xsl:value-of select="./@Amount"/></xsl:attribute>
<xsl:attribute name="IncreaseIndicator"><xsl:value-of select="./@IncreaseIndicator"/></xsl:attribute>
<asap:AgencyIdentifier>
<xsl:for-each select="./asap:AgencyIdentifier/asap:PrimaryAgencyIdentifier">
<asap:PrimaryAgencyIdentifier>
<xsl:value-of select="."/>
<xsl:variable name="agencyLocationCode" select="./@AgencyLocationCode"/>
<!-- The variable agencyLocationCode can be used for further processing. -->


<xsl:attribute name="AgencyLocationCode"><xsl:value-of select="$agencyLocationCode"/></xsl:attribute>
</asap:PrimaryAgencyIdentifier>
</xsl:for-each>
</asap:AgencyIdentifier>
<asap:RecipientIdentifier>
<xsl:value-of select="./asap:RecipientIdentifier"/>
<xsl:variable name="recipientIdentifier" select="./asap:RecipientIdentifier/@RecipientIdentifier"/>
<!-- The variable recipientIdentifier can be used for further processing. -->


<xsl:attribute name="RecipientIdentifier"><xsl:value-of select="$recipientIdentifier"/></xsl:attribute>
</asap:RecipientIdentifier>
</asap:AuthorizationRequest>
</xsl:for-each>
</asap:CreateAuthorizationRequest>
</asap:AccountServicesTransmission>
</xsl:template>
</xsl:stylesheet>

Parents
  • Suggested Answer

    0  

    Your XSL has a couple of issues.  

    The line <xsl:stylesheet version="1.0" xmlns:asap="urn:us:gov:treas:fms:Payment:AccountAuthorization:2.1" xmlns:xsl="">www.w3.org/.../Transform">

    is ill formed.

    Also, <asap:RecipientIdentifier> is followed by <xsl:value-of select="./asap:RecipientIdentifier"/>.

    I'm guessing that you don't want "<xsl:value-of select="./asap:RecipientIdentifier"/>".

    Here is what I'm guessing your XSL file should be

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:asap="urn:us:gov:treas:fms:Payment:AccountAuthorization:2.1"
                    xmlns:xsl="">www.w3.org/.../Transform">
      <xsl:template match="/">
        <asap:AccountServicesTransmission>
          <xsl:variable name="cycleDate" select="/asap:AccountServicesTransmission/@CycleDate"/>
          <!-- The variable cycleDate can be used for further processing. -->


          <xsl:attribute name="CycleDate">
            <xsl:value-of select="$cycleDate"/>
          </xsl:attribute>
          <xsl:attribute name="FileNumber">
            <xsl:value-of select="/asap:AccountServicesTransmission/@FileNumber"/>
          </xsl:attribute>
          <xsl:attribute name="TestIndicator">
            <xsl:value-of select="/asap:AccountServicesTransmission/@TestIndicator"/>
          </xsl:attribute>
          <xsl:attribute name="TransmissionTimestamp">
            <xsl:value-of select="/asap:AccountServicesTransmission/@TransmissionTimestamp"/>
          </xsl:attribute>
          <asap:CreateAuthorizationRequest>
            <xsl:variable name="effectiveDate" select="/asap:AccountServicesTransmission/asap:CreateAuthorizationRequest/@EffectiveDate"/>
            <!-- The variable effectiveDate can be used for further processing. -->


            <xsl:attribute name="EffectiveDate">
              <xsl:value-of select="$effectiveDate"/>
            </xsl:attribute>
            <xsl:for-each select="/asap:AccountServicesTransmission/asap:CreateAuthorizationRequest/asap:AuthorizationRequest">
              <asap:AuthorizationRequest>
                <xsl:variable name="accountIdentifier" select="./@AccountIdentifier"/>
                <!-- The variable accountIdentifier can be used for further processing. -->


                <xsl:attribute name="AccountIdentifier">
                  <xsl:value-of select="$accountIdentifier"/>
                </xsl:attribute>
                <xsl:attribute name="Amount">
                  <xsl:value-of select="./@Amount"/>
                </xsl:attribute>
                <xsl:attribute name="IncreaseIndicator">
                  <xsl:value-of select="./@IncreaseIndicator"/>
                </xsl:attribute>
                <asap:AgencyIdentifier>
                  <xsl:for-each select="./asap:AgencyIdentifier/asap:PrimaryAgencyIdentifier">
                    <asap:PrimaryAgencyIdentifier>
                      <xsl:value-of select="."/>
                      <xsl:variable name="agencyLocationCode" select="./@AgencyLocationCode"/>
                      <!-- The variable agencyLocationCode can be used for further processing. -->


                      <xsl:attribute name="AgencyLocationCode">
                        <xsl:value-of select="$agencyLocationCode"/>
                      </xsl:attribute>
                    </asap:PrimaryAgencyIdentifier>
                  </xsl:for-each>
                </asap:AgencyIdentifier>
                <asap:RecipientIdentifier>
                  <!-- <xsl:value-of select="./asap:RecipientIdentifier"/> -->
                  <xsl:variable name="recipientIdentifier" select="./asap:RecipientIdentifier/@RecipientIdentifier"/>
                  <!-- The variable recipientIdentifier can be used for further processing. -->


                  <xsl:attribute name="RecipientId">
                    <xsl:value-of select="$recipientIdentifier"/>
                  </xsl:attribute>
                </asap:RecipientIdentifier>
              </asap:AuthorizationRequest>
            </xsl:for-each>
          </asap:CreateAuthorizationRequest>
        </asap:AccountServicesTransmission>
      </xsl:template>
    </xsl:stylesheet>

  • 0 in reply to   

    thank you I really appreciate you looking at that. I have one more question.   I have been playing with my stylesheet and got it to work with out the for-each on the elements.  My CreateAuthorizationRequest tag can repeat multiple times as well as other tags under it.  When I try to add the xsl:for-each in my stylesheet it doesn't work any longer.  How do you handle tags that can repeat multiple times in a stylesheet that XML extension will understand.   

Reply
  • 0 in reply to   

    thank you I really appreciate you looking at that. I have one more question.   I have been playing with my stylesheet and got it to work with out the for-each on the elements.  My CreateAuthorizationRequest tag can repeat multiple times as well as other tags under it.  When I try to add the xsl:for-each in my stylesheet it doesn't work any longer.  How do you handle tags that can repeat multiple times in a stylesheet that XML extension will understand.   

Children
  • 0 in reply to 

    I was able to get get my XSL to work finally.  I am posting it here in case someone else has the same issue.  <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:asap="urn:us:gov:treas:fms:Payment:AccountAuthorization:2.1" xmlns:xsl="">www.w3.org/.../Transform" >
    <xsl:output method="xml" encoding="UTF-8"/>
    <xsl:template match="/">
       <xsl:apply-templates select="acct-serv-trans" />
    </xsl:template>
    <xsl:template match="acct-serv-trans">
    <asap:AccountServicesTransmission>
    <xsl:attribute name="CycleDate">
    <xsl:value-of select="cycle-date/text()"/>
    </xsl:attribute>
    <xsl:attribute name="FileNumber">
    <xsl:value-of select="file-no/text()"/>
    </xsl:attribute>
    <xsl:attribute name="TestIndicator">
    <xsl:value-of select="test-id/text()"/>
    </xsl:attribute>
    <xsl:attribute name="TransmissionTimestamp">
    <xsl:value-of select="time-stamp/text()"/>
    </xsl:attribute>
    <xsl:for-each select="./create-request">
    <asap:CreateAuthorizationRequest>
    <xsl:attribute name="EffectiveDate">
    <xsl:value-of select="eff-date/text()"/>
    </xsl:attribute>
    <asap:AuthorizationRequest>
    <xsl:attribute name="AccountIdentifier">
    <xsl:value-of select="author-request/acct-id/text()"/>
    </xsl:attribute>
    <xsl:attribute name="Amount">
    <xsl:value-of select="author-request/amount/text()"/>
    </xsl:attribute>
    <xsl:attribute name="IncreasIndicator">
    <xsl:value-of select="author-request/incr-ind/text()"/>
    </xsl:attribute>
    <asap:AgencyIdentifier>
    <asap:PrimaryAgencyIdentifier>
    <xsl:attribute name="AgencyLocationCode">
    <xsl:value-of select="author-request/agency-ind/agency-loc/text()"/>
    </xsl:attribute>
    </asap:PrimaryAgencyIdentifier>
    </asap:AgencyIdentifier>
    <asap:RecipientIdentifier>
    <xsl:attribute name="RecipientIdentifier">
    <xsl:value-of select="author-request/recp-ind/recipient-ind/text()"/>
    </xsl:attribute>
    </asap:RecipientIdentifier>
    </asap:AuthorizationRequest>
    </asap:CreateAuthorizationRequest>
    </xsl:for-each>
    </asap:AccountServicesTransmission>
    </xsl:template>
    </xsl:stylesheet>