Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

XML Sax Parser issue

77 views
Skip to first unread message

mohan

unread,
May 13, 2015, 12:07:02 AM5/13/15
to
Hello All,

We have an AL developed with TDI 7.0 that uses File system connector with XML SAX parser. After upgrading TDI to V7.1.1 we are experiencing issue with parser. After connecting to XML file when we try to get parameter values it throw an error. If someone have experienced same issue please suggest if you know any fix.

error:
CTGDJZ108E The Entry from the queue is a message.class = java.io.IOException, message = java.io.IOException: Read error.java.lang.Exception: CTGDJZ108E The Entry from the queue is a message.class = java.io.IOException, message = java.io.IOException: Read error

at
com.ibm.di.parser.XMLSaxParser.readEntry(XMLSaxParser.java:311)
at
com.ibm.di.connector.FileConnector.getNextEntry(Fileconnector.java:244)
at
com.ibm.tdi.eclipse.widget.DiscoverSchemaWidget$QueryJob.run(DiscoverSchemaWidget.java:730)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)



Thanks for your help!

Mohan-

Eddie Hartman

unread,
May 14, 2015, 10:50:38 AM5/14/15
to
Hi Mohan,

Have you tried with the new XML Parser? If you set the Simple Path param of the parser to "*" and the Entry Tag to empty string, then it parses the entire XML into a single Entry (the Work Entry).

Then you can use w3c DOMInterface calls to search and modify the hierarchical tree of data.

list = work.getElementsByTagName("Person");
for (person in list) {
... do as you will.

Here's a ref to the getElementsByTagName() call show above:
http://www.stephen-swann.co.uk/javadoc/tdi7.1.1/com/ibm/di/entry/Entry.html#getElementsByTagName(java.lang.String)

You can do all sorts of stuff with an entry to work with hierarchical data:
work.toJSON()
work.fromJSON(jsonString)
work.toXML()
work.fromXML(xmlString, "*", "")
to name a few. And of course the Javascript engine in TDI (SDI) has built in toJson() and fromJson() calls.

Makes working with XML and JSON a breeze.
There are some vids and write-ups on the subject, but not enough yet.
http://www.tdiingoutloud.com/2013/09/json-and-xml-tutorial-part-1.html
http://www.tdiingoutloud.com/2015/02/json-and-xml-tutorial-part-2.html
https://www.youtube.com/watch?v=L9nKRvoq-SU

For those interested in mastering hierarchical data, which there will be more and more of as JSON spreads:
http://www.w3.org/TR/DOM-Level-2-Core/core.html

As to the AJAX Parser in particular, I suggest opening a ticket with our excellent support team. They'll get you an answer to your original question. And please share it when you get tit :)

mohan

unread,
May 17, 2015, 11:57:17 PM5/17/15
to
Hello Eddie,

Thanks for your help!

I am trying to read the XML file to check its footer count and AdminList value. Below is the example of XML file that I am using. I use to read XML file with filesystem connector using SAX parser. But now I cannot read it with SAX parser in TDI V7.1.1.

<?xml version="1.0" encoding="UTF-8" ?>
<AdminList process="immediate" fileDateTimeStamp="2010-10-27T14:14:36.9456672-07:00" client="ABC" xmlns="urn:www-example-com:exm-2013-11">
<AdminUser>
<UserIdentifier>ABCD-123456</UserIdentifier>
<UserOneTimeToken>ABCD-123456</UserOneTimeToken>
<UserStatus>active</UserStatus>
<FirstName>John</FirstName>
<LastName>Smith</LastName>
</AdminUser>
<AdminListFooter adminCount="1"/>
</AdminList>


I need to read "AdminList" parameter (<AdminList process="immediate")in this example and <AdminListFooter adminCount="1"/> into my work. Can you please suggest?

Thanks,
Mohan-

Eddie Hartman

unread,
May 27, 2015, 5:23:08 AM5/27/15
to
// first read in the file, Mohan
file = system.openFileForInput(filename);
strbuf = new java.lang.StringBuffer();
do {
line = file.readLine();
If (line != null) {
strbuf.append(line);
}
} while (line != null)

// convert to hEntry (hierarchical Entry)
hentry = work.fromXML(strbuf.toString(),'*','');

// get the node(s) you want
nodeList = hentry.getElementsByTagName('AdminListFooter');
if (nodeList.getLength() > 0) {
// you expect only one
node = nodeList[1];

// xml node attributes appear with '@' prepended to their name
work.adminCount = node.@adminCount;
}

Same procedure for <AdminList>, so you could script a function to return node attribute names 'x' froma node named 'y'
0 new messages