JBASE XML converter commands

  • msurii
  • Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
16 years 4 months ago #2550 by msurii
JBASE XML converter commands was created by msurii
The below sample will explain you the jbase build in READXML & WRITEXML command usage.

PROGRAM XML.SAMPLE.RTN
!Sample program shows XML conversion from data file
FN.CUSTOMER='F.CUSTOMER';F.CUSTOMER=''
CALL OPF(FN.CUSTOMER,F.CUSTOMER)
FN.UFD='&UFD&';F.UFD=''
OPEN FN.UFD TO F.UFD ELSE STOP '&UFD& NOT FOUND'
CRT 'ENTER THE RECORD NAME=': ;INPUT REC.ID
!Convert plain data record to XML
READXML XML.REC FROM F.CUSTOMER,REC.ID THEN
CRT 'XML REC =':XML.REC
END
!
!
!Convert XML to plain data record
CRT 'CHECK &UFD& RECORD ':REC.ID
WRITEXML XML.REC TO F.UFD,REC.ID ON ERROR CRT "ERROR WRITING REC " :REC.ID
!
STOP

Please Log in or Create an account to join the conversation.

More
14 years 6 months ago #6087 by originative

Please Log in or Create an account to join the conversation.

  • jorsep6979
  • Visitor
  • Visitor
14 years 1 month ago #7679 by jorsep6979
Replied by jorsep6979 on topic Re: JBASE XML converter commands
To use this commands we have to create a dict for the XML file, How can I do it?

Regards,

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
14 years 1 month ago #7699 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
The record in the corresponding DICT is named @READXML and has to be a valid XSL.

For CUSTOMER e.g. something like
*File DICT F.CUSTOMER , Record '@READXML'
Command->
0001 <?xml version="1.0" ?>
0002 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
0003
0004 <xsl:template match="/">
0005 <CUSTOMER>
0006
0007 <xsl:for-each select="array/data">
0008
0009 <xsl:if test="@attribute=1">
0010  <MNEMONIC><xsl:value-of select="."/></MNEMONIC>
0011 </xsl:if>
0012 <xsl:if test="@attribute=2">
0013  <SHORT.NAME><xsl:value-of select="."/></SHORT.NAME>
0014 </xsl:if>
0015 <xsl:if test="@attribute=3">
0016  <NAME.1><xsl:value-of select="."/></NAME.1>
0017 </xsl:if>
0018 <xsl:if test="@attribute=4">
0019  <NAME.2><xsl:value-of select="."/></NAME.2>
0020 </xsl:if>
0021 <xsl:if test="@attribute=5">
0022  <STREET><xsl:value-of select="."/></STREET>
0023 </xsl:if>
0024 <xsl:if test="@attribute=6">
0025  <ADDRESS><xsl:value-of select="."/></ADDRESS>
0026 </xsl:if>
0027 <xsl:if test="@attribute=7">
0028  <TOWN.COUNTRY><xsl:value-of select="."/></TOWN.COUNTRY>
0029 </xsl:if>
0030 <xsl:if test="@attribute=8">
0031  <POST.CODE><xsl:value-of select="."/></POST.CODE>
0032 </xsl:if>
0033 <xsl:if test="@attribute=9">
0034  <COUNTRY><xsl:value-of select="."/></COUNTRY>
0035 </xsl:if>
0036 <xsl:if test="@attribute=10">
0037  <RELATION.CODE><xsl:value-of select="."/></RELATION.CODE>
0038 </xsl:if>
0039 <xsl:if test="@attribute=11">
0040  <REL.CUSTOMER><xsl:value-of select="."/></REL.CUSTOMER>
0041 </xsl:if>
0042
0043 <xsl:if test="@attribute=178 and @value=1">
0044     <CUST.PRFT.CENT><xsl:value-of select="."/></CUST.PRFT.CENT>
0045 </xsl:if>
0046 <xsl:if test="@attribute=178 and @value=2">
0047     <EU.STATUS><xsl:value-of select="."/></EU.STATUS>
0048 </xsl:if>
0049 <xsl:if test="@attribute=178 and @value=3">
0050     <VARIANCE.CODE><xsl:value-of select="."/></VARIANCE.CODE>
0051 </xsl:if>
0052 <xsl:if test="@attribute=178 and @value=4">
0053     <TICKET.FEE.CODE><xsl:value-of select="."/></TICKET.FEE.CODE>
0054 </xsl:if>
0055 <xsl:if test="@attribute=178 and @value=5">
0056     <TAX.DOMICILE><xsl:value-of select="."/></TAX.DOMICILE>
0057 </xsl:if>
0058
0059 </xsl:for-each>
0060
0061 </CUSTOMER>
0062 </xsl:template>
0063
0064 </xsl:stylesheet>

The extraction of the LOCAL.REF (and other MV fields) can be made better, but I'm not an expert in XML/XSL.

If you play around with the @READXML don't forget to re-signon after each change, the record is cached.

Please Log in or Create an account to join the conversation.

  • jorsep6979
  • Visitor
  • Visitor
14 years 1 month ago #7724 by jorsep6979
Replied by jorsep6979 on topic Re: JBASE XML converter commands
Thank you very much jpb, It work very good!!



Is the same for the DYNTOXML jbase function? Where the xsl has to be?

Regards,

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
14 years 1 month ago #7726 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
As I remember to have to rad the xsl for the other transformations within your routine (READ XSLREC FROM dir,id ...) and use this rec when executing the command (or hardcode it in the routine).

Please Log in or Create an account to join the conversation.

  • jorsep6979
  • Visitor
  • Visitor
14 years 3 weeks ago #7870 by jorsep6979
Replied by jorsep6979 on topic Re: JBASE XML converter commands
Hi jpb,

In READXML only one record can be convert it to xml?
For example if I want to read the CUSTOMER table and write an XML with all customer records Can I use READXML? How can I do it?

Regards

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #10119 by ALTIN
Replied by ALTIN on topic Re: JBASE XML converter commands
Hi,

I use codes below for create xml but I always get an error which is this...

** Error [ XML_ERROR ] **
XML conversion failed, error number -1 on file ../bnk.data/st/FBNK.CUST000
Line 20 , Source TB.BURAK.DENEME
Trap from an error message, error message name = XML_ERROR
Source changed to /opt/globus9/TBASTP3/bnk/bnk.run/TBSRC.BP/TB.BURAK.DENEME
0020 READXML xml FROM F.CUSTOMER,CUS.ID THEN


CODE :

PROGRAM TB.BURAK.DENEME

$INSERT I_COMMON
$INSERT I_EQUATE

FN.CUSTOMER = "F.CUSTOMER"
F.CUSTOMER = ""
R.CUSTOMER = ""
CALL OPF(FN.CUSTOMER, F.CUSTOMER)

CUS.ID = "115364"

READXML xml FROM F.CUSTOMER,CUS.ID THEN
CRT xml
END


Please Help Me...

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
13 years 5 months ago #10124 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
Check your xsl in @READXML, the routine works.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #10128 by ALTIN
Replied by ALTIN on topic Re: JBASE XML converter commands
My @READXML file is below...

File DICT F.CUSTOMER , Record '@READXML'
Command->
0001 <?xml version="1.0" ?>
0002 <xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/1999/XSL/Transform">
0003 <xsl:template match="/">
0004 <CUSTOMER>
0005
0006 <xsl:for-each select="array/data">
0007
0008 <xsl:if test="@attribute=1">
0009 <MNEMONIC><xsl:value-of select="."/></MNEMONIC>
0010 </xsl:if>
0011 <xsl:if test="@attribute=2">
0012 <SHORT.NAME><xsl:value-of select="."/></SHORT.NAME>
0013 </xsl:if>
0014 <xsl:if test="@attribute=3">
0015 <NAME.1><xsl:value-of select="."/></NAME.1>
0016 </xsl:if>
0017 <xsl:if test="@attribute=4">
0018 <NAME.2><xsl:value-of select="."/></NAME.2>
0019 </xsl:if>
0020 <xsl:if test="@attribute=5">
0021 <STREET><xsl:value-of select="."/></STREET>
0022 </xsl:if>
0023 </xsl:for-each>
0024 </CUSTOMER>
0025 </xsl:template>
0026
0027 </xsl:stylesheet>
0028

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
13 years 5 months ago - 13 years 5 months ago #10130 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

makes a difference, but I suppose it's replaced by kuena ?!?

With "http://" your @READXML works fine for me, what is your jBase / TAFC release ?


What do you get when you try to READXML from a file where no @READXML exists. The default xml (showing <data attribute="1" value="1" subvalue="1"> etc.) should work in any case...
Last edit: 13 years 5 months ago by jpb.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago - 13 years 5 months ago #10131 by ALTIN
Replied by ALTIN on topic Re: JBASE XML converter commands
I don't know TAFC version but T24 R9.

It works for the empty @READXML.

The problem is @READXML record as I understand.

For create a record I use commands below. Maybe I 'm doing smthg wrong.

1-)
jsh tbastp3 ~ -->JED DICT F.CUSTOMER
Record Keys : @READXML

2-)
NEW *File DICT F.CUSTOMER , Record '@READXML'
Command->
0001 <?xml version="1.0" ?>
0002 <xsl:stylesheet version="1.0" xmlns:xsl="www.w3.org/1999/XSL/Transform">
0003 <xsl:template match="/">
0004 <CUSTOMER>
0005
0006 <xsl:for-each select="array/data">
0007
0008 <xsl:if test="@attribute=1">
0009 <MNEMONIC><xsl:value-of select="."/></MNEMONIC>
0010 </xsl:if>
0011 <xsl:if test="@attribute=2">
0012 <SHORT.NAME><xsl:value-of select="."/></SHORT.NAME>
0013 </xsl:if>
0014 <xsl:if test="@attribute=3">
0015 <NAME.1><xsl:value-of select="."/></NAME.1>
0016 </xsl:if>
0017 <xsl:if test="@attribute=4">
0018 <NAME.2><xsl:value-of select="."/></NAME.2>
0019 </xsl:if>
0020 <xsl:if test="@attribute=5">
0021 <STREET><xsl:value-of select="."/></STREET>
0022 </xsl:if>
0023 </xsl:for-each>
0024 </CUSTOMER>
0025 </xsl:template>
0026
0027 </xsl:stylesheet>
End Of Record
Last edit: 13 years 5 months ago by ALTIN.

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
13 years 5 months ago #10132 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
What do you get when you try to READXML from a file where no @READXML exists. The default xml (showing <data attribute="1" value="1" subvalue="1"> etc.) should work in any case...

[as above]

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
13 years 5 months ago #10133 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
You can see your jBase with

jdiag -h

but it should be fine with R09 and with a valid response for default.

I copied your @READXML and it also works.
Try using it line by line.

Please Log in or Create an account to join the conversation.

More
13 years 5 months ago #10134 by ALTIN
Replied by ALTIN on topic Re: JBASE XML converter commands
I dont know why but It not work.


jsh tbastp3 ~ -->jdiag -h
jdiag - jBASE diagnostic '$Revision: 1.15 $'

System Information
==================

System : AIX trkshaix 1.6 00F692014C00
OS Release : 6.1.6.0
UNIX User : tbastp3 (uid 294, euid 294)
Tty name : /dev/pts/18
Time : Fri Jan 20 15:30:46 2012

Please Log in or Create an account to join the conversation.

  • jpb
  • jpb's Avatar
  • Offline
  • Moderator
  • Moderator
  • retired . . . ¯\_(ツ)_/¯
More
13 years 5 months ago #10135 by jpb
Replied by jpb on topic Re: JBASE XML converter commands
Sorry - jBase version is not in header, just type jdiag ans^d look for RELEASE . . .

As the error seems to be in the @READXML I would start to run your routine without a @READXML in place and then let it grow attribute by attribute.

Don't forget to logout/-in after each change of @READXML.

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds