Jump to content
Changes to the Jaspersoft community edition download ×

tFileInputXML: java and perl, different result


Recommended Posts



I was playing around with extracting data from a xml-file, namely the iTunes Music Libaray.xml, which is where iTunes stores information about tracks in the iTunes-libarary.

So I tried the tFileInputXML component and some xPath-queries to extract some data that was of interest.


First something about the xml-file:


One problem for me with the iTunes Music Libarary.xml file is that it uses key-value pairs where the values are 'interger' or 'string' instead of tags 'Track ID' with a value resulting in a more complex query.

This is an example what the file can look like:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<key>Major Version</key><integer>1</integer>
<key>Minor Version</key><integer>1</integer>
<key>Application Version</key><string>7.2</string>
<key>Show Content Ratings</key><true/>
<key>Music Folder</key><string>file://localhost/D:/music/</string>
<key>Library Persistent ID</key><string>E2F1C84137ADF1F9</string>
<key>Track ID</key><integer>192</integer>
<key>Name</key><string>03 Dear Can</string>
<key>Album</key><string>Louden Up Now</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Total Time</key><integer>277185</integer>
<key>Track Number</key><integer>3</integer>
<key>Track Count</key><integer>10</integer>
<key>Date Modified</key><date>2007-04-27T11:33:26Z</date>
<key>Date Added</key><date>2007-05-24T08:47:41Z</date>
<key>Bit Rate</key><integer>192</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Persistent ID</key><string>EB130C0FFAD7A62C</string>
<key>Track Type</key><string>File</string>
<key>File Folder Count</key><integer>3</integer>
<key>Library Folder Count</key><integer>1</integer>


[url=http://www.xml.com/pub/a/2004/11/03/itunes.html]And here is a good page that describes the file iTunes Music Libray.xml



Now to my problem (or if it's a bug):


This was my first try with JasperETL (and for some reason I started a Java-project).

And because there was quite awhile since I played around with xPath I had problems to understand why my quieries didn't return the result that I expected.

It was when I tested a Perl-project with same queries and got the result that I expected that suspicions that this might be a bug arose.


But still I'm not sure. Mainly because I'm not sure if my queries are correct.


In the properties for tFileInputXML I have:





[code]"./key[contains(.,'Track ID')]//following-sibling::node()[1]"



[code]"./key[contains(.,'Play Count')]/following-sibling::node()[1]"



'id' returned the result that i expected.

'play_count' works as long as there is a Key with value 'Play Count'


The error I get is that if there is no key 'Play Count', the play_count get the same value as the last time the was a key 'Play Count'.

That is for 'Java'.


But whe I run the same query in 'Perl' the play_count result is an empty string as I expect it to be.


So all of this ends up in my questions:

Is this a bug or is my xPath query incorrect?

And if it's a bug, where do I register it?


And of course when i tested the Perl-project i realised that 'Perl' was a lot faster than 'Java'.


Best Regards


Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...