You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jason <ja...@yahoo.com> on 2005/10/25 03:44:22 UTC
Progressive Parse
Hello,
I'm in the process of converting a C++ project to java
and I have a quick question. The project uses the
xercesc progressive parse parseFirst( ), parseNext( )
pair and I'm wondering if the equivalent functionality
exists in xercesj? I can't find it if it does.
Thanks in advance to anyone who can offer a definitive
answer on the issue.
-jason
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Progressive Parse
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Jason <ja...@yahoo.com> wrote on 10/25/2005 12:17:32 PM:
> Thanks Michael,
>
> One other question (to you or anyone else). The
> project I'm converting uses the progressive parse in
> conjunction with the SAX interfaces. Frankly, the
> advantage of the progressive parse isn't clear to me.
> I poked around the xercesc documentation which
> explains the use of this part of the API but not the
> use case it satisfies. So, what are the advantages to
> using the progressive parse in conjunction with the
> sax callbacks versus just using the standard parser
> apis? Thanks in advance.
It gives your application more control over the parsing process. The
common approach to stopping a SAX parser is to throw a SAXException from
one of your handlers, but once you've done that you've terminated the
parser. With an XMLPullParsingConfiguration you can stop parsing whenever
you want, do something else and then resume parsing if you choose. You can
process several documents in the same thread using this approach.
> -jason
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Having trouble factorying a progressive pull parser
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Jason,
The SAXParser has a constructor [1] which takes an XMLParserConfiguration
as a parameter. You could create the parser using this constructor and
still get the benefit of pull parser configuration if you call the
setupInputSource() and parse() method on the parser configuration (instead
of the parser() method on the SAXParser). The configuration will send the
document events to the SAXParser which will in turn be reported to your
ContentHandler.
Hope that helps.
[1]
http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/parsers/SAXParser.html#SAXParser(org.apache.xerces.xni.parser.XMLParserConfiguration)
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Jason <ja...@yahoo.com> wrote on 10/31/2005 12:51:13 PM:
> Michael,
>
> Thanks again. I was slightly misled by the names
> ending with 'Configuration' in that I thought they
> should somehow be used to configure a parser rather
> than to act as a parser themselves. In any event, I
> think I've finally got things straightened out. Just
> to make sure I'm not confused: if I'm using the xni
> PullParserConfiguration I have to use the
> xni.XMLDocumentHandler class in order to get my
> callbacks rather than the normal ContentHandler. Is
> that true or is there some way to use ContentHandler
> in conjunction with a pull parser? Thanks again for
> your help.
>
> -jason
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Having trouble factorying a progressive pull parser
Posted by Jason <ja...@yahoo.com>.
Michael,
Thanks again. I was slightly misled by the names
ending with 'Configuration' in that I thought they
should somehow be used to configure a parser rather
than to act as a parser themselves. In any event, I
think I've finally got things straightened out. Just
to make sure I'm not confused: if I'm using the xni
PullParserConfiguration I have to use the
xni.XMLDocumentHandler class in order to get my
callbacks rather than the normal ContentHandler. Is
that true or is there some way to use ContentHandler
in conjunction with a pull parser? Thanks again for
your help.
-jason
--- Michael Glavassevich <mr...@ca.ibm.com> wrote:
> Jason,
>
> There's no magic service for obtaining
> XMLPullParserConfigurations. The
> default parser configuration:
>
org.apache.xerces.parsers.XIncludeAwareParserConfiguration
> implements
>
org.apache.xerces.xni.parser.XMLPullParserConfiguration.
> It has public
> constructors. You can create it directly. The other
> available parser
> configurations are listed here [1].
>
> Thanks.
>
> [1]
> http://xml.apache.org/xerces2-j/faq-xni.html#faq-3
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
> Jason <ja...@yahoo.com> wrote on 10/27/2005
> 04:49:46 PM:
>
> > Hello,
> >
> > I'm trying to use the methods in the interface
> >
>
org.apache.xerces.xni.parser.XMLPullParserConfiguration
> > and I can't figure out how to create an instance
> of a
> > parser which implements it. I've made two
> attempts -
> > the first is to run this code:
> >
> > //Begin Code
> > public static void main(String[] args) throws
> > Exception
> > {
> > XMLParserConfiguration parserConfig = null;
> >
> > // create parser configuration
> > try
> > {
> > parserConfig =
> >
> >
>
(XMLParserConfiguration)ObjectFactory.newInstance("org.apache.
> > xerces.xni.parser.XMLPullParserConfiguration",
> >
> ObjectFactory.findClassLoader(),
> > true);
> >
> > }
> > catch (Exception e)
> > {
> > System.err.println("error: Unable to
> instantiate
> > parser configuration
> >
>
org.apache.xerces.xni.parser.XMLPullParserConfiguration");
> > }
> >
> > // XMLDocumentParser parser = new
> > XMLDocumentParser(parserConfig);
> > //End Code
> >
> > Getting this code to compile involved copying
> > ObjectFactory.java and SecuritySupport.java from
> the
> > samples/xni directory and building them along with
> my
> > test code. When I run the class I get this error:
> >
> > Exception in thread "main"
> > ObjectFactory$ConfigurationError: Provider
> >
>
org.apache.xerces.xni.parser.XMLPullParserConfiguration
> > could not be instantiated:
> > java.lang.InstantiationException:
> >
>
org.apache.xerces.xni.parser.XMLPullParserConfiguration
> > at
> > ObjectFactory.newInstance(ObjectFactory.java:346)
> > at
> PullParserTest.main(PullParserTest.java:35)
> >
> > I also tried launching the VM like so:
> >
> > java
> >
>
-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.
> > xerces.xni.parser.XMLPullParserConfiguration
> > PullParserTest ADMAdapterOutput.xml
> >
> > but that didn't help. I've poked around the
> > documentation quite a bit but I'm still in the
> dark.
> > Am I making this harder than need be? Can anyone
> > provide me with a bit of code to create a
> PullParser
> > instance? Thanks in advance.
> >
> > -jason
> >
> >
> >
> >
> >
> > __________________________________
> > Yahoo! FareChase: Search multiple travel sites in
> one click.
> > http://farechase.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail:
> j-users-help@xerces.apache.org
> >
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail:
> j-users-help@xerces.apache.org
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Having trouble factorying a progressive pull parser
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Jason,
There's no magic service for obtaining XMLPullParserConfigurations. The
default parser configuration:
org.apache.xerces.parsers.XIncludeAwareParserConfiguration implements
org.apache.xerces.xni.parser.XMLPullParserConfiguration. It has public
constructors. You can create it directly. The other available parser
configurations are listed here [1].
Thanks.
[1] http://xml.apache.org/xerces2-j/faq-xni.html#faq-3
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Jason <ja...@yahoo.com> wrote on 10/27/2005 04:49:46 PM:
> Hello,
>
> I'm trying to use the methods in the interface
> org.apache.xerces.xni.parser.XMLPullParserConfiguration
> and I can't figure out how to create an instance of a
> parser which implements it. I've made two attempts -
> the first is to run this code:
>
> //Begin Code
> public static void main(String[] args) throws
> Exception
> {
> XMLParserConfiguration parserConfig = null;
>
> // create parser configuration
> try
> {
> parserConfig =
>
> (XMLParserConfiguration)ObjectFactory.newInstance("org.apache.
> xerces.xni.parser.XMLPullParserConfiguration",
> ObjectFactory.findClassLoader(),
> true);
>
> }
> catch (Exception e)
> {
> System.err.println("error: Unable to instantiate
> parser configuration
> org.apache.xerces.xni.parser.XMLPullParserConfiguration");
> }
>
> // XMLDocumentParser parser = new
> XMLDocumentParser(parserConfig);
> //End Code
>
> Getting this code to compile involved copying
> ObjectFactory.java and SecuritySupport.java from the
> samples/xni directory and building them along with my
> test code. When I run the class I get this error:
>
> Exception in thread "main"
> ObjectFactory$ConfigurationError: Provider
> org.apache.xerces.xni.parser.XMLPullParserConfiguration
> could not be instantiated:
> java.lang.InstantiationException:
> org.apache.xerces.xni.parser.XMLPullParserConfiguration
> at
> ObjectFactory.newInstance(ObjectFactory.java:346)
> at PullParserTest.main(PullParserTest.java:35)
>
> I also tried launching the VM like so:
>
> java
> -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.
> xerces.xni.parser.XMLPullParserConfiguration
> PullParserTest ADMAdapterOutput.xml
>
> but that didn't help. I've poked around the
> documentation quite a bit but I'm still in the dark.
> Am I making this harder than need be? Can anyone
> provide me with a bit of code to create a PullParser
> instance? Thanks in advance.
>
> -jason
>
>
>
>
>
> __________________________________
> Yahoo! FareChase: Search multiple travel sites in one click.
> http://farechase.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Having trouble factorying a progressive pull parser
Posted by Jason <ja...@yahoo.com>.
Hello,
I'm trying to use the methods in the interface
org.apache.xerces.xni.parser.XMLPullParserConfiguration
and I can't figure out how to create an instance of a
parser which implements it. I've made two attempts -
the first is to run this code:
//Begin Code
public static void main(String[] args) throws
Exception
{
XMLParserConfiguration parserConfig = null;
// create parser configuration
try
{
parserConfig =
(XMLParserConfiguration)ObjectFactory.newInstance("org.apache.xerces.xni.parser.XMLPullParserConfiguration",
ObjectFactory.findClassLoader(),
true);
}
catch (Exception e)
{
System.err.println("error: Unable to instantiate
parser configuration
org.apache.xerces.xni.parser.XMLPullParserConfiguration");
}
// XMLDocumentParser parser = new
XMLDocumentParser(parserConfig);
//End Code
Getting this code to compile involved copying
ObjectFactory.java and SecuritySupport.java from the
samples/xni directory and building them along with my
test code. When I run the class I get this error:
Exception in thread "main"
ObjectFactory$ConfigurationError: Provider
org.apache.xerces.xni.parser.XMLPullParserConfiguration
could not be instantiated:
java.lang.InstantiationException:
org.apache.xerces.xni.parser.XMLPullParserConfiguration
at
ObjectFactory.newInstance(ObjectFactory.java:346)
at PullParserTest.main(PullParserTest.java:35)
I also tried launching the VM like so:
java
-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.xni.parser.XMLPullParserConfiguration
PullParserTest ADMAdapterOutput.xml
but that didn't help. I've poked around the
documentation quite a bit but I'm still in the dark.
Am I making this harder than need be? Can anyone
provide me with a bit of code to create a PullParser
instance? Thanks in advance.
-jason
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Progressive Parse
Posted by Jason <ja...@yahoo.com>.
Thanks Michael,
One other question (to you or anyone else). The
project I'm converting uses the progressive parse in
conjunction with the SAX interfaces. Frankly, the
advantage of the progressive parse isn't clear to me.
I poked around the xercesc documentation which
explains the use of this part of the API but not the
use case it satisfies. So, what are the advantages to
using the progressive parse in conjunction with the
sax callbacks versus just using the standard parser
apis? Thanks in advance.
-jason
--- Michael Glavassevich <mr...@ca.ibm.com> wrote:
> Jason <ja...@yahoo.com> wrote on 10/24/2005
> 09:44:22 PM:
>
> > Hello,
> >
> > I'm in the process of converting a C++ project to
> java
> > and I have a quick question. The project uses the
> > xercesc progressive parse parseFirst( ),
> parseNext( )
> > pair and I'm wondering if the equivalent
> functionality
> > exists in xercesj?
>
> There is an equivalent but you have to use XNI
> directly. Have a look at
> XMLPullParserConfiguration [1]. Most (if not all) of
> the parser
> configurations [2] which ship with the parser
> implement this interface.
>
> > I can't find it if it does.
> > Thanks in advance to anyone who can offer a
> definitive
> > answer on the issue.
> >
> > -jason
> >
> >
> >
> >
> > __________________________________
> > Yahoo! Mail - PC Magazine Editors' Choice 2005
> > http://mail.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> > For additional commands, e-mail:
> j-users-help@xerces.apache.org
> >
>
> [1]
>
http://xml.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/parser/XMLPullParserConfiguration.html
> [2]
> http://xml.apache.org/xerces2-j/faq-xni.html#faq-3
>
> Michael Glavassevich
> XML Parser Development
> IBM Toronto Lab
> E-mail: mrglavas@ca.ibm.com
> E-mail: mrglavas@apache.org
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail:
> j-users-help@xerces.apache.org
>
>
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
Re: Progressive Parse
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Jason <ja...@yahoo.com> wrote on 10/24/2005 09:44:22 PM:
> Hello,
>
> I'm in the process of converting a C++ project to java
> and I have a quick question. The project uses the
> xercesc progressive parse parseFirst( ), parseNext( )
> pair and I'm wondering if the equivalent functionality
> exists in xercesj?
There is an equivalent but you have to use XNI directly. Have a look at
XMLPullParserConfiguration [1]. Most (if not all) of the parser
configurations [2] which ship with the parser implement this interface.
> I can't find it if it does.
> Thanks in advance to anyone who can offer a definitive
> answer on the issue.
>
> -jason
>
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors' Choice 2005
> http://mail.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
[1]
http://xml.apache.org/xerces2-j/javadocs/xni/org/apache/xerces/xni/parser/XMLPullParserConfiguration.html
[2] http://xml.apache.org/xerces2-j/faq-xni.html#faq-3
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org