Importing data to matlab - Missing important XML attribute

434 views
Skip to first unread message

Douglas

unread,
Sep 15, 2009, 4:13:56 AM9/15/09
to ViPER Mailing List
Hi,

I was nearly going to give up but I seem to have made some small
progress in importing ViPER data into Matlab. However, I am
stuck again. I hope that you, or somone, can assist.

Sorry, if you are seeing this question again. I tagged it onto the end
of a previous post then realised it deserves a new subject.


This is what I have done in Matlab:

>> import javax.xml.parsers.*
>> docBuilder = DocumentBuilderFactory.newInstance()
>> docElement = docBuilder.newDocumentBuilder().parse('test.xgtf').getDocumentElement()
>> parser = viper.api.impl.ViperParser
>> parser.parseDoc(docElement)

14-Sep-2009 15:26:41 viper.api.datatypes.Lvalue setConfig

WARNING: lvalues should enumerate all possible values in the <lvalue-
possibles> tag.

14-Sep-2009 15:26:41 viper.api.impl.ViperParser parseAttr

SEVERE: Missing important XML attribute.

java.lang.NullPointerException

at viper.api.impl.ViperParser.parseAttr(Unknown Source)

at viper.api.impl.ViperParser.parseAttrs(Unknown Source)

at viper.api.impl.ViperParser.parseSourcefile(Unknown Source)

at viper.api.impl.ViperParser.parseData(Unknown Source)

at viper.api.impl.ViperParser.parseDoc(Unknown Source)

14-Sep-2009 15:26:41 viper.api.impl.ViperParser parseAttr

SEVERE: Missing important XML attribute.

java.lang.NullPointerException

......

And the xml file is:

<?xml version="1.0" encoding="UTF-8"?>
<viper xmlns="http://lamp.cfar.umd.edu/viper#" xmlns:data="http://
lamp.cfar.umd.edu/viperdata#">
<config>
<descriptor name="Information" type="FILE">
<attribute dynamic="false" name="SOURCETYPE" type="http://
lamp.cfar.umd.edu/viperdata#lvalue">
<data:lvalue-possibles>
<data:lvalue-enum value="SEQUENCE"/>
<data:lvalue-enum value="FRAMES"/>
</data:lvalue-possibles>
</attribute>
<attribute dynamic="false" name="NUMFRAMES" type="http://
lamp.cfar.umd.edu/viperdata#dvalue"/>
<attribute dynamic="false" name="FRAMERATE" type="http://
lamp.cfar.umd.edu/viperdata#fvalue"/>
<attribute dynamic="false" name="H-FRAME-SIZE"
type="http://lamp.cfar.umd.edu/viperdata#dvalue"/>
<attribute dynamic="false" name="V-FRAME-SIZE"
type="http://lamp.cfar.umd.edu/viperdata#dvalue"/>
</descriptor>
<descriptor name="People" type="OBJECT">
<attribute dynamic="false" name="Bounding box"
type="http://lamp.cfar.umd.edu/viperdata#circle"/>
</descriptor>
</config>
<data>
<sourcefile filename="file:/C:/Documents%20and%20Settings/
dougmacd/Desktop/testSequence/test_images/test_images.info">
<file id="0" name="Information">

......ETC

I feel I am so close to getting this working.

Thank you for your kind help,

Douglas

David Mihalcik

unread,
Sep 15, 2009, 7:40:11 AM9/15/09
to viper-...@googlegroups.com
I think this should fix it:

>>> import javax.xml.parsers.*
>>> docBuilder = DocumentBuilderFactory.newInstance()

docBuilder.setNamespaceAware(true)

>>> docElement = docBuilder.newDocumentBuilder().parse('test.xgtf').getDocumentElement()
>>> parser = viper.api.impl.ViperParser
>>> parser.parseDoc(docElement)

David Mihalcik

Douglas

unread,
Sep 15, 2009, 11:21:19 AM9/15/09
to ViPER Mailing List
Brilliant! It works!

On Sep 15, 12:40 pm, David Mihalcik <kraka...@gmail.com> wrote:
> I think this should fix it:
>
> >>> import javax.xml.parsers.*
> >>> docBuilder = DocumentBuilderFactory.newInstance()
>
> docBuilder.setNamespaceAware(true)
>
> >>> docElement = docBuilder.newDocumentBuilder().parse('test.xgtf').getDocumentElement()
> >>> parser = viper.api.impl.ViperParser
> >>> parser.parseDoc(docElement)
>
> David Mihalcik
>

nicknack

unread,
Aug 4, 2012, 4:44:31 PM8/4/12
to viper-...@googlegroups.com
Hi Douglas and David,

I followed your steps and now have a viper object in matlab after calling parser.parseDoc(docElement). I would now like to read the info from this object. Is there sample code somewhere that could help me with that? I am new to java by the way.

Thanks
Nikhil
Reply all
Reply to author
Forward
0 new messages