JBASE XML converter commands
- msurii
- Topic Author
- Offline
- Premium Member
-
- Posts: 89
- Thank you received: 1
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.
- originative
- Offline
- New Member
-
- Posts: 13
- Thank you received: 1
www.tutorialjinni.com/2010/11/write-xml-...s-t24-infobasic.html
www.tutorialjinni.com/2010/11/read-xml-i...s-t24-infobasic.html
Please Log in or Create an account to join the conversation.
- jorsep6979
- Visitor
-
Regards,
Please Log in or Create an account to join the conversation.
- jpb
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
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
-
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
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
Please Log in or Create an account to join the conversation.
- jorsep6979
- Visitor
-
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.
- ALTIN
- Offline
- New Member
-
- Posts: 4
- Thank you received: 0
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
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
Please Log in or Create an account to join the conversation.
- ALTIN
- Offline
- New Member
-
- Posts: 4
- Thank you received: 0
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
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
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...
Please Log in or Create an account to join the conversation.
- ALTIN
- Offline
- New Member
-
- Posts: 4
- Thank you received: 0
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
Please Log in or Create an account to join the conversation.
- jpb
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
[as above]
Please Log in or Create an account to join the conversation.
- jpb
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
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.
- ALTIN
- Offline
- New Member
-
- Posts: 4
- Thank you received: 0
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
-
- Offline
- Moderator
-
- retired . . . ¯\_(ツ)_/¯
- Posts: 2859
- Thank you received: 650
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.