I have recently downloaded the XMLi package and have compiled it on a V6R1 machine. Creating XML directly from RPG code works quite well, and now I am exploring templates. So far, I am not having any luck generating XML via templates. This includes using the RPG and template examples provided in the XMLILIB library. When compiling and executing the programs, they complete with no error messages, but no output is generated. Are there any tips on initial setup that could be investigated (permissions, config file, etc.)? Thanks for your help.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Apologies for not getting back sooner - will need to check why I don't seem to get the mails from this forum! :-)
When you say the examples you are running generate no output, are you saying the XML files are not appearing in the directory you are expecting them to appear in?
If this is the case you will need to check a couple of basic things (apologies if you have already done this):
1. Does the directory exist?
2. Do you have authority to write to that directory?
If you're not sure about authority, pick a directory you KNOW you can create streamfiles in and modify one of the standard templates to write to that directory and then re-run the standard template.
The configuration set up in xmli_config.xml (which comes with the package) should suite you fine, and will be the default configuration file the utility would use if you do not specify one. Certainly ensure the config file exists in /XMLi/config or alternatively tell XMLi where your own configuration file is located.
If you know how to use QSH you can replace the write-to-file tag with a write-to-stdout tag and call from the command shell. The output will print on the screen for you. You would execute the standard programs within the shell by entering /QSYS.LIB/XMLILIB.LIB/EXAMPLE12.PGM (for example) and pressing Enter.
If you are still experiencing problems please post your template xml here and I'll take a look at it.
Cheers
Larry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
All of the authorities seem to be correct. There is one thing I have noticed as I have attempted to trace through the program. When loading the template, the first lp_event is *XML_START_DOCUMENT. The very next event is *XML_END_DOCUMENT. So the program can find my template, but it seems to immediately end after it starts. The template is listed below. Thanks again.
<!- Run SQL statement and build XML from the results ->
<rss>
<SalesImport>
<items>
<!- Run SQL to get all records from HLMSLSSUMP (sql-naming is set to SQL) ->
<xmli:run-sql name="sales" statement="select *
from hlmslssump">
</xmli:run-sql>
<!- For each row found, write the XML ->
<xmli:for-each>
<item>
<LeaseNumber><xmli:value-of select="sales.1" /></LeaseNumber>
<GLCode><xmli:value-of select="sales.2" /></GLCode>
<Amount><xmli:value-of select="sales.3" /></Amount>
<Month><xmli:value-of select="sales.4" /></Month>
<Year><xmli:value-of select="sales.5" /></Year>
</item>
</xmli:for-each>
</items>
</SalesImport>
</rss>
<!- The result is written to the IFS in the path specified ->
<xmli:write-to-file path="'/finance/SalesToAccruent.xml'" />
</xmli:template>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As you can see from the first line of my template, there has been some adjustments made from the original examples supplied by the installation (mainly, the namespace). When I went back and made sure the xml_config.xml file and the namespaces in the templates were all set back to the post-installation versions, everything started working. I was able to successfully execute a template containing a SQL statement. You will also notice the library missing from the SQL statement above; that was another adjustment that needed to be made.
So as of now I am in great shape, and I believe these templates will provide some nice opportunities for us. Thanks so much for your assistance.
jl4au
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have recently downloaded the XMLi package and have compiled it on a V6R1 machine. Creating XML directly from RPG code works quite well, and now I am exploring templates. So far, I am not having any luck generating XML via templates. This includes using the RPG and template examples provided in the XMLILIB library. When compiling and executing the programs, they complete with no error messages, but no output is generated. Are there any tips on initial setup that could be investigated (permissions, config file, etc.)? Thanks for your help.
Hi ji4au,
Apologies for not getting back sooner - will need to check why I don't seem to get the mails from this forum! :-)
When you say the examples you are running generate no output, are you saying the XML files are not appearing in the directory you are expecting them to appear in?
If this is the case you will need to check a couple of basic things (apologies if you have already done this):
1. Does the directory exist?
2. Do you have authority to write to that directory?
If you're not sure about authority, pick a directory you KNOW you can create streamfiles in and modify one of the standard templates to write to that directory and then re-run the standard template.
The configuration set up in xmli_config.xml (which comes with the package) should suite you fine, and will be the default configuration file the utility would use if you do not specify one. Certainly ensure the config file exists in /XMLi/config or alternatively tell XMLi where your own configuration file is located.
If you know how to use QSH you can replace the write-to-file tag with a write-to-stdout tag and call from the command shell. The output will print on the screen for you. You would execute the standard programs within the shell by entering /QSYS.LIB/XMLILIB.LIB/EXAMPLE12.PGM (for example) and pressing Enter.
If you are still experiencing problems please post your template xml here and I'll take a look at it.
Cheers
Larry
All of the authorities seem to be correct. There is one thing I have noticed as I have attempted to trace through the program. When loading the template, the first lp_event is *XML_START_DOCUMENT. The very next event is *XML_END_DOCUMENT. So the program can find my template, but it seems to immediately end after it starts. The template is listed below. Thanks again.
<xmli:template xmlns:xmli="http://www.hibbett.com/xml_templates" sql-naming="SQL" format="pretty">
<!- Run SQL statement and build XML from the results ->
<rss>
<SalesImport>
<items>
<!- Run SQL to get all records from HLMSLSSUMP (sql-naming is set to SQL) ->
<xmli:run-sql name="sales" statement="select *
from hlmslssump">
</xmli:run-sql>
<!- For each row found, write the XML ->
<xmli:for-each>
<item>
<LeaseNumber><xmli:value-of select="sales.1" /></LeaseNumber>
<GLCode><xmli:value-of select="sales.2" /></GLCode>
<Amount><xmli:value-of select="sales.3" /></Amount>
<Month><xmli:value-of select="sales.4" /></Month>
<Year><xmli:value-of select="sales.5" /></Year>
</item>
</xmli:for-each>
</items>
</SalesImport>
</rss>
<!- The result is written to the IFS in the path specified ->
<xmli:write-to-file path="'/finance/SalesToAccruent.xml'" />
</xmli:template>
Larry,
As you can see from the first line of my template, there has been some adjustments made from the original examples supplied by the installation (mainly, the namespace). When I went back and made sure the xml_config.xml file and the namespaces in the templates were all set back to the post-installation versions, everything started working. I was able to successfully execute a template containing a SQL statement. You will also notice the library missing from the SQL statement above; that was another adjustment that needed to be made.
So as of now I am in great shape, and I believe these templates will provide some nice opportunities for us. Thanks so much for your assistance.
jl4au