Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
Claire1 Absent Member.
Absent Member.
1881 views

C$XML Disable initial comment in generated XML

Jump to solution

Sorry to revive an old question, but I'd like to know if it's now possible with extend 9 or 10 to disable the initial comment in XML generated by C$XML (original filename and "generated by ACUCOBOL-GT", etc). This has been asked in the past, but there was never much of an answer. 

Since C$XML does pretty much what I want, I'd rather not get into other solutions like XML Extensions. I've already tried deleting the comment with CXML-DELETE-COMMENT, but it doesn't seem to be handled like a normal comment in the XML. I can't even access it with CXML-GET-COMMENT, like I can with comments I've added myself.

Is there some trick or configuration setting for getting rid of this comment?

 

Thanks,

Claire

 

COMMENT

0 Likes
6 Solutions

Accepted Solutions
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Run an XSL transform as a post-generation step.  This could be done by executing a command line XSL processor as appropriate for your operating system.

The XSL you need is an identity transform with a template added to match comment nodes and eliminate them.  The following would be a good starting point for such a transform:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="www.w3.org/.../Transform" version="1.0">

<xsl:template match = "@*|node()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()|processing-instruction()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="comment()"/>

</xsl:stylesheet>

The first <xsl:template> is the classic identity transform.  The second <xsl:template> matches all comment nodes and eliminates them by the fact that the template does not create any output.

I can supply some more information if you want to supply the OS identity.


Tom Morrison
Consultant

View solution in original post

0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Claire,

I created a Jscript script which can be found in the last two entries on this thread (no login needed):

http://www.tek-tips.com/viewthread.cfm?qid=1723716

I am sure it could be improved by a better JScript programmer, but again it is a starting point.


Tom Morrison
Consultant

View solution in original post

0 Likes
Chuck Edgin Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
Tom - Rather than rely on an external script (Powershell, Jscript), wouldn't it make more sense to invoke the XSLT directly from the ACUCOBOL program using XML TRANSFORM FILE? Claire mentions "extend 9 or 10" and I believe XML Extensions is available in either of those versions (I don't recall now in exactly which version it was introduced, but I know for sure it's in 10 since that's what I'm using).

Claire - unless Tom sees an issue using it, I don't think there'd be any conflict using a combination of C$XML and XML Extensions in this way - you'd still create the file with your current usage of C$XML, then post-process it with XML TRANSFORM FILE.

View solution in original post

0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Since Claire expressed a preference for other than XML Extensions, I devised a solution that did not use XML Extensions. I am not sure what the licensing scheme is for XML Extensions on AcuCOBOL, or what operational issues it may present for Clair. Of course, I would prefer to use XML Extensions, and yes XML TRANSFORM FILE would have the identical effect of applying an XSLT transformation and would have the further benefit of being OS agnostic.

[Chuck, hope you are doing well.]


Tom Morrison
Consultant

View solution in original post

0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

"it won't always have quite the same structure, so I wanted the flexibility"

Please understand, Claire, that I am not suggesting a rewrite of something you probably already have working.  However,...

I have a lot of experience in the world of XML.  I strongly believe that a (mostly) functional programming approach to building XML documents (XSLT) is highly preferred to a procedural approach (C$XML).  I have used other procedural languages (VB, C, to some extent C#) to build and consume XML documents, and I find that there is so much 'busy-ness' in all the logic to build/consume a document, that clarity is sacrificed.  And if clarity is sacrificed, future maintenance costs will be much higher.

I also have an intuition that using XSLT to process documents provides a clear separation between data and its representation, much like the old argument about having a user interface layer, business rules layer, data store layer, etc.  Having this type of separation allows the selection of tools that best fit each layer.

Now, to go directly to the point of your statement - that the use of C$XML is going to provide more flexibility than an XSLT approach.  I cannot imagine a situation where this is true.  XSLT has a complete set of control flow statements, so all the decisions that can be made in the COBOL program can be made with the control flow statements in XSLT.  While XSLT does not have an assignment statement, this is almost never a constraint.

And, just to show who's boss, the COBOL program can decide to use different XSLT in different situations, though I find this is rarely needed.  The one time I have done this on a consistent basis is where the consuming application can demand either XML or JSON (typically as a web service response).  Oh, wait... what happens if you are suddenly required to produce JSON instead of XML?  Will C$XML output JSON - without rewriting more than two or three lines of the COBOL program?

So, Clair, there is no right way or wrong way.  C$XML is working for you, and I hope that it continues to serve you well in the future.  But, in a future project where you have a chance to change the development approach, please give XSLT (and therefore XML Extensions) serious consideration. 

Best of luck!


Tom Morrison
Consultant

View solution in original post

0 Likes
Micro Focus Expert
Micro Focus Expert

RE: C$XML Disable initial comment in generated XML

Jump to solution
Have you tried the examples ... C:\Users\Public\Documents\Micro Focus\extend 10.1.0\sample\xmlext there's a bat file in that directory to compile and run those examples.

View solution in original post

0 Likes
16 Replies
Micro Focus Expert
Micro Focus Expert

RE: C$XML Disable initial comment in generated XML

Jump to solution
No, there isn't a configuration variable or work around when using C$XML to get rid of the "generated by" line in the XML file.
0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Run an XSL transform as a post-generation step.  This could be done by executing a command line XSL processor as appropriate for your operating system.

The XSL you need is an identity transform with a template added to match comment nodes and eliminate them.  The following would be a good starting point for such a transform:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="www.w3.org/.../Transform" version="1.0">

<xsl:template match = "@*|node()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="@*|node()|processing-instruction()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="comment()"/>

</xsl:stylesheet>

The first <xsl:template> is the classic identity transform.  The second <xsl:template> matches all comment nodes and eliminates them by the fact that the template does not create any output.

I can supply some more information if you want to supply the OS identity.


Tom Morrison
Consultant

View solution in original post

0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
Thanks, this sounds like something we could try. We're using Windows. Is there a command line XSL processor that you can recommend?

Claire
0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Claire,

I created a Jscript script which can be found in the last two entries on this thread (no login needed):

http://www.tek-tips.com/viewthread.cfm?qid=1723716

I am sure it could be improved by a better JScript programmer, but again it is a starting point.


Tom Morrison
Consultant

View solution in original post

0 Likes
Chuck Edgin Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
Tom - Rather than rely on an external script (Powershell, Jscript), wouldn't it make more sense to invoke the XSLT directly from the ACUCOBOL program using XML TRANSFORM FILE? Claire mentions "extend 9 or 10" and I believe XML Extensions is available in either of those versions (I don't recall now in exactly which version it was introduced, but I know for sure it's in 10 since that's what I'm using).

Claire - unless Tom sees an issue using it, I don't think there'd be any conflict using a combination of C$XML and XML Extensions in this way - you'd still create the file with your current usage of C$XML, then post-process it with XML TRANSFORM FILE.

View solution in original post

0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

Since Claire expressed a preference for other than XML Extensions, I devised a solution that did not use XML Extensions. I am not sure what the licensing scheme is for XML Extensions on AcuCOBOL, or what operational issues it may present for Clair. Of course, I would prefer to use XML Extensions, and yes XML TRANSFORM FILE would have the identical effect of applying an XSLT transformation and would have the further benefit of being OS agnostic.

[Chuck, hope you are doing well.]


Tom Morrison
Consultant

View solution in original post

0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
I don't mind using XML Extensions for post-processing. C$XML just seemed like a good choice for generating the file, because it won't always have quite the same structure, so I wanted the flexibility. We have extend 10, although we're still using 9 in production. I can check and see what's available in extend 9 and experiment with these suggestions later this week.

Thanks for the ideas!

Claire
0 Likes
Knowledge Partner
Knowledge Partner

RE: C$XML Disable initial comment in generated XML

Jump to solution

"it won't always have quite the same structure, so I wanted the flexibility"

Please understand, Claire, that I am not suggesting a rewrite of something you probably already have working.  However,...

I have a lot of experience in the world of XML.  I strongly believe that a (mostly) functional programming approach to building XML documents (XSLT) is highly preferred to a procedural approach (C$XML).  I have used other procedural languages (VB, C, to some extent C#) to build and consume XML documents, and I find that there is so much 'busy-ness' in all the logic to build/consume a document, that clarity is sacrificed.  And if clarity is sacrificed, future maintenance costs will be much higher.

I also have an intuition that using XSLT to process documents provides a clear separation between data and its representation, much like the old argument about having a user interface layer, business rules layer, data store layer, etc.  Having this type of separation allows the selection of tools that best fit each layer.

Now, to go directly to the point of your statement - that the use of C$XML is going to provide more flexibility than an XSLT approach.  I cannot imagine a situation where this is true.  XSLT has a complete set of control flow statements, so all the decisions that can be made in the COBOL program can be made with the control flow statements in XSLT.  While XSLT does not have an assignment statement, this is almost never a constraint.

And, just to show who's boss, the COBOL program can decide to use different XSLT in different situations, though I find this is rarely needed.  The one time I have done this on a consistent basis is where the consuming application can demand either XML or JSON (typically as a web service response).  Oh, wait... what happens if you are suddenly required to produce JSON instead of XML?  Will C$XML output JSON - without rewriting more than two or three lines of the COBOL program?

So, Clair, there is no right way or wrong way.  C$XML is working for you, and I hope that it continues to serve you well in the future.  But, in a future project where you have a chance to change the development approach, please give XSLT (and therefore XML Extensions) serious consideration. 

Best of luck!


Tom Morrison
Consultant

View solution in original post

0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
Actually, I'm still fairly early in the development process with this. I just wanted to go ahead and address the C$XML initial comment issue, to see what could be done about it. If you highly recommend XML Extensions over C$XML and find it sufficiently flexible, then I'm willing to give that a try.
0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
I'm trying out XML Extensions, but I get a memory access violation on the "XML INITIALIZE" statement.

I'm using the recommended copy files, compiling with -Ze, and starting up the runtime with -y xmlif.dll .

I normally use extend 10 for development, compile with backwards compatibility for 9.2 and run with 9.2, but I've also tried compiling for the latest version and running with 10. I always get a memory access violation. I've checked out the licensing, and XML Extensions seems to be included with ACUCOBOL-GT in both versions 9 and 10. I'm using Windows 7.

Any ideas what might be causing it?
0 Likes
Chuck Edgin Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
This may require contacting Micro Focus Supportline - but can you provide the OS version, the actual extend version (10.0, 10.0.1, etc.) and whether you're using the 32 or 64-bit runtime?
0 Likes
Micro Focus Expert
Micro Focus Expert

RE: C$XML Disable initial comment in generated XML

Jump to solution
Have you tried the examples ... C:\Users\Public\Documents\Micro Focus\extend 10.1.0\sample\xmlext there's a bat file in that directory to compile and run those examples.

View solution in original post

0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
I'm running Windows 7 Professional, 64-bit, and I've tested this with extend 10.1.0 (+ a number of ECNs) and with 9.2.5, both 32-bit runtimes.
0 Likes
Claire1 Absent Member.
Absent Member.

RE: C$XML Disable initial comment in generated XML

Jump to solution
I was able to get the examples to run. It seems that there's something about the combination of XML Extensions and our application that causes the memory access violation. When I tried running a test program as a standalone, it worked fine, but when I called it from within our application, I got the memory access violation. Unfortunately I don't have the time to investigate it thoroughly, so it looks like I'll need to stick with C$XML for this.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.