Hi,
I have a requirement wherein I have to process a compressed file
containing multiple xml files (lets say AllXMLs.tar.gz)....I have to
parse all the XML files without uncompressing them.
I can use the classes available in java.util.zip package to create
InputStream for the contents of the XML files..But can the XML Pull
parser process it...??
Currently when I am passing the Input Stream to the Parser, I get
the following exception:
Exception in thread "main" org.gjt.xpp.XmlPullParserException: only
whitespace content allowed outside root element at
ine 2 and column 3 seen "...<?xml version="1.0" encoding="ISO-8859-
1"?>\n"... (parser state CONTENT)
at org.gjt.xpp.impl.pullparser.PullParser.next
(PullParser.java:429)
at ZipParser.readGZIPFile(ZipParser.java:62)
at ZipParser.main(ZipParser.java:17)
My function looks something like this:
private static void readGZIPFile(String fileName) throws Exception
{
// use BufferedReader to get one line at a time
BufferedReader gzipReader = null;
XmlPullParserFactory factory =
XmlPullParserFactory.newInstance();
XmlPullParser pp = factory.newPullParser();
pp.setAllowedMixedContent(true);
try
{
// simple loop to dump the contents to the
console
gzipReader = new BufferedReader( new
InputStreamReader( new GZIPInputStream(new FileInputStream
(fileName))));
while (gzipReader.ready())
{
pp.setInput(gzipReader);
// input could be also taken from
String directly:
//pp.setInput(data.toCharArray());
// 4. parsing
//declare variables used during
parsing
XmlStartTag stag =
factory.newStartTag();
XmlEndTag etag = factory.newEndTag();
byte type; // received event type
byte prevType; // previous event
type
type = prevType = pp.next();
if(type == XmlPullParser.START_TAG) {
pp.readStartTag(stag);
//System.err.println("read
start tag "+stag);
if(! "test".equals
(stag.getLocalName())) {
throw new
RuntimeException("bulk data must start with test not "
+stag.getLocalName()
+pp.getPosDesc());
}
} else {
throw new RuntimeException
("unexpected end of data "+pp.getPosDesc());
}
// start parsing loop
for(;;) {
type = pp.next();
if(type ==
XmlPullParser.START_TAG) {
pp.readStartTag
(stag);
//System.err.println
("read start tag "+stag);
type = pp.next();
String content = "";
if(type ==
XmlPullParser.CONTENT) {
content =
pp.readContent();
//System.err.println("read content="+content);
while(type !
= XmlPullParser.END_TAG) {
try {
type = pp.next();
}
catch(Exception e){
System.err.println("ERROR recovering from "+e);
// give it a second chance
//type = pp.next();
type = pp.getEventType();
}
}
}
if(type !=
XmlPullParser.END_TAG) {
throw new
RuntimeException("expected end tag not "+pp.getPosDesc());
}
System.err.println
("LOAD tag="+stag.getLocalName()+" data='"+content+"'");
} else if(type ==
XmlPullParser.END_TAG) {
break;
} else if(type ==
XmlPullParser.END_DOCUMENT) {
throw new
RuntimeException("unexpected end of data "+pp.getPosDesc());
} else {
throw new
RuntimeException("unknown event type: "+type);
}
}
}
gzipReader.close();
}
catch (FileNotFoundException fnfe)
{
System.out.println("The file was not
found: " + fnfe.getMessage());
}
catch (IOException ioe)
{
System.out.println("An IOException
occurred: " + ioe.getMessage());
}
finally
{
if (gzipReader != null)
{
try
{
gzipReader.close();
}
catch (IOException ioe)
{
}
}
}
}
Can you please advise
osccookie wrote:
> Hi all,
>
> I'm using KXml for a while now, but I keep getting the same errors...
>
> I'll explain it with an example, when <test> is the currently parsed
> element, and I perform:
> int eventType = parser.next();
>
> On the following XML:
> <test>125</test>
> <test>
> <call/>
> </test>
>
> In both cases, the eventType is TEXT... While in the second <test>, I
> want it to be START_TAG...
> The method parser.isWhitespace() doesn't help either, because it makes
> the parser skip the value 125, suggesting "125" is a whitespace...
>
> Any solutions?
>
did you try to call nextTag() to move to tags?
HTH,
alek
> Thanks a lot in advance!!
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay
Hi all,
I'm using KXml for a while now, but I keep getting the same errors...
I'll explain it with an example, when <test> is the currently parsed
element, and I perform:
int eventType = parser.next();
On the following XML:
<test>125</test>
<test>
<call/>
</test>
In both cases, the eventType is TEXT... While in the second <test>, I
want it to be START_TAG...
The method parser.isWhitespace() doesn't help either, because it makes
the parser skip the value 125, suggesting "125" is a whitespace...
Any solutions?
Thanks a lot in advance!!
ALT Mobile (http://altmobile.com) is pleased to announce the
availability of the <alt> XML Studio v6. Providing XML-centric
development tools for the Enterprise XML, Web 2.0, and Mobile Internet
markets, the XML Studio provides the following major features related
to XPP:
1. Pull-Parse Tool. Providing a visual front-end to XPP, our "Pull
Parse Tool" provides the following capabilities:
1.1 Analyze the structure of an XML document.
1.2 Visualize either the entire XML document or parts of its structure.
1.3 Split an XML document based on its structure into several smaller
documents.
2. XML Visualization. Our DOM Browser and HyperDOM technologies
implement state-of-the-art visualization technologies which are
coupled with innovations in object-oriented and direct manipulation
user interface technologies.
3. High Performance XML Processing Components. To enable the
processing of large XML data sets and ease of use for common
development scenarios, we have created new processing architectures
and built higher-level XML APIs. These APIs provide an "Exclude
Others"-style of processing as opposed to the "Include All"-style
provided by SAX and DOM, etc.
Our XPP-based pull parser component supports the following new APIs:
3.1. Element findElementNamed (String element, int increment)
3.2. Element getNextElement()
3.3. Element parseURLAndCopyElementAtIncrement(String url, String
namespace, String element, int increment)
3.4. parseURLAndSerialize(String url, Vector elementNames, String
absoluteFilePath)
A second high-performance component is based on regular expressions
and NIO and supports these APIs:
3.5. StringBuffer findSerializedElements (String element, boolean
isEmptyElement)
3.6. StringBuffer findSerializedElementAtIncrement
String elementNameString, boolean isEmptyElement, int increment)
3.7. StringBuffer findSerializedElementsBetweenIncrements (String
element, boolean isEmptyElement, int beginIncrement, int endIncrement)
3.8. NodeList findElements (String element, boolean isEmptyElement)
3.9 Element findElementAtIncrement (String element, boolean
isEmptyElement, int increment)
3.10 NodeList findElementsBetweenIncrements (String element, boolean
isEmptyElement, int beginIncrement, int endIncrement
4. XML Analytics and Reporting. Our Node Insight technology provides
developers with everything from namespace usage information to
attribute value reporting. By instrumenting XPP, our pull parser
component reports on several XML metrics.
5. Web Services and Java APIs. All the visual tools and components
provide an XML-RPC API and a Java language API enable access from tool
chains, IDEs, and batch programs. The pull parser component and regex
component remote APIs are:
5.1. hyperVisualizeURLUsingPullParser(String url, Vector elements)
5.2. hyperVisualizeAndSerializeURLUsingPullParser(String url,
Vector elements, String filePathString)
5.3. serializeURLUsingPullParserAtIncrement(String url, String
element, int serializeIncrement, String absoluteDirPath)
5.4. serializeURLUsingPullParser(String url, Vector elements, String
filePath)
5.5. parseFileUsingRegexAndFindSerializedElements(String pathString,
String element, boolean isEmptyElement)
5.6. parseFileUsingRegexAndFindSerializedElementBetweenIncrements(
String pathString, String element, boolean isEmptyElement, int
beginIncrement, int endIncrement)
5.7. parseFileUsingRegexAndFindSerializedElementAtIncrement(String
path, String element, boolean isEmptyElement, int extractIncrement)
Available on OS X, Windows XP, and RedHat Linux. Cost is set at USD
1000 per copy for a commercial license and USD 100 for a personal
license. Of course, contributors to XPP may request a free copy.
Hi - here's a pom.xml for building xni2xml with Maven 2. It depends
on the xmlpull api, which I don't think is in a Internet accessable
repository. I had to download the xmlpull api from the website, and
install it into my local repository. After installing the xmlpull api
into your local repository this pom should work.
Hope this helps someone!
Elliot
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.xmlpull</groupId>
<artifactId>xmlpull-xni2xml</artifactId>
<packaging>jar</packaging>
<name>XNI XML Pull Parser</name>
<version>1.0.0-SNAPSHOT</version>
<url>http://sourceforge.net/projects/xni2xmlpull/</url>
<!--
<organization>
<name/>
<url/>
</organization>
-->
<properties>
<xmlpull-api.version>1.1.3.4b</xmlpull-api.version>
<xstream.version>1.1.3</xstream.version>
<xpp3.version>1.1.3.3</xpp3.version>
<xerces-impl.version>2.8.0</xerces-impl.version>
</properties>
<dependencies>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>${xpp3.version}</version>
</dependency>
<dependency>
<groupId>org.xmlpull</groupId>
<artifactId>xmlpull-api</artifactId>
<version>${xmlpull-api.version}</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>${xerces-impl.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/java/xmlpull_v1_impl/</sourceDirectory>
</build>
</project>
--- In xmlpull-user@yahoogroups.com, "fibremux999" <emetsger@...> wrote:
<snip>
> Ok, so I have entities defined in my document declaration that aren't
> being resolved. I'm not sure yet if it is an parser issue or an
> XStream issue.
It seems to be an Elliot issue. I was creating the parser via the
X2ParserFactory thus:
XmlPullParserFactory factory = X2ParserFactory.newInstance();
parser = factory.newPullParser();
But apparently that doesn't do what I need. Instead I created the
parser directly:
parser = new X2Parser( );
And everything is working! Entity resolution and all! Not quite sure
what's up with the factory but that is probably pilot error.
Thanks,
Elliot
>
> Am looking deeper.
>
> Elliot
>
> --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> wrote:
> >
> > XPP3 does nto support DOCDECL feature instead pull from CVS
xni2xmlpull
> > and use it instead (assuming sourceforge cvs works ...)
> >
> > http://sourceforge.net/projects/xni2xmlpull/
> >
> > let me know if you have problems with it (if it works ok i may
just make
> > an official release of xni2xmkpull)
> >
> > best,
> >
> > alek
> >
> > fibremux999 wrote:
> > > Ack. Ok, for the record I'm working with XStream 1.1.3. My
apologies
> > > if this is really an XStream question (flame away!)
> > >
> > > XStream has three main interfaces:
> > > HierarchicalStreamDriver
> > > HierarchicalStreamReader
> > > HierarchicalStreamWriter
> > >
> > > ... and there is a corresponding Xpp implementation for each of
those
> > > interfaces.
> > >
> > > What I've done is extended the Xpp driver and reader implementations
> > > (I don't care about writer) and I've overridden certain methods to
> > > enable the DOCDECL feature.
> > >
> > > However, I'm getting this stack trace [0] when I attempt to set the
> > > feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> > > 1.1.3.3 from the IBiblio maven repository
> > > (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
> > >
> > > The exception puzzles me because it originates from
> > > org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> > > an incorrect or older version of Xpp?
> > >
> > > Thanks for your guidance to someone who knows enough to be
dangerous,
> > > Elliot
> > >
> > > [0] Exception below:
> > >
> > > Exception in thread "main"
> > > edu.jhu.library.scratch.xstream.InitializationException: Unable to
> > > create an XmlPullParser with feature
> > > http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> > > at
> com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> > > at
> > >
>
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> > > at
> > >
> edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> > > at
> edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> > > Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> > > is not supported
> > > at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> > > ... 6 more
> > >
> > >
> > >
> > >
> > > --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> > > wrote:
> > >
> > >> fibremux999 wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> I'm working with some software that uses xpp3 as its parser.
> However
> > >>> the software as it is designed doesn't allow me to have access
> to the
> > >>> parser factory.
> > >>>
> > >>> Since I don't have access to the parser factory, I'm unable to
call
> > >>> the setFeature() method on the factoy. Specifically I need to
> enable
> > >>> the FEATURE_PROCESS_DOCDECL
> > >>> (http://xmlpull.org/v1/doc/features.html#process-docdecl)
feature.
> > >>>
> > >>> Am I able to enable factory features by setting a system
> property, or
> > >>> can that only be done via the setFeature() method itself?
> > >>>
> > >>> I've attempted to set a variety of system properties, none of
which
> > >>> seem to work.
> > >>>
> > >>>
> > >> if you know the parser implementation class name you can create it
> > >> directly without factory and call setFeature on that parser
(that is
> > >> what factory is typically doing)
> > >>
> > >> HTH,
> > >>
> > >> alek
> > >>
> > >> --
> > >> The best way to predict the future is to invent it - Alan Kay
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > The best way to predict the future is to invent it - Alan Kay
> >
>
--- In xmlpull-user@yahoogroups.com, "fibremux999" <emetsger@...> wrote:
> Ok, so I have entities defined in my document declaration that aren't
> being resolved. I'm not sure yet if it is an parser issue or an
> XStream issue.
This was an Elliot issue. I was instatiating the parser like so:
XmlPullParserFactory factory = X2ParserFactory.newInstance();
parser = factory.newPullParser();
But that wasn't working for me. I was getting an instance of another
parser. So I just instantiated the X2Parser directly, and all is
well! DOCDECL is being read, entities are being resolved -
Thanks,
Elliot
>
> --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> wrote:
> >
> > XPP3 does nto support DOCDECL feature instead pull from CVS
xni2xmlpull
> > and use it instead (assuming sourceforge cvs works ...)
> >
> > http://sourceforge.net/projects/xni2xmlpull/
> >
> > let me know if you have problems with it (if it works ok i may
just make
> > an official release of xni2xmkpull)
> >
> > best,
> >
> > alek
> >
> > fibremux999 wrote:
> > > Ack. Ok, for the record I'm working with XStream 1.1.3. My
apologies
> > > if this is really an XStream question (flame away!)
> > >
> > > XStream has three main interfaces:
> > > HierarchicalStreamDriver
> > > HierarchicalStreamReader
> > > HierarchicalStreamWriter
> > >
> > > ... and there is a corresponding Xpp implementation for each of
those
> > > interfaces.
> > >
> > > What I've done is extended the Xpp driver and reader implementations
> > > (I don't care about writer) and I've overridden certain methods to
> > > enable the DOCDECL feature.
> > >
> > > However, I'm getting this stack trace [0] when I attempt to set the
> > > feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> > > 1.1.3.3 from the IBiblio maven repository
> > > (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
> > >
> > > The exception puzzles me because it originates from
> > > org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> > > an incorrect or older version of Xpp?
> > >
> > > Thanks for your guidance to someone who knows enough to be
dangerous,
> > > Elliot
> > >
> > > [0] Exception below:
> > >
> > > Exception in thread "main"
> > > edu.jhu.library.scratch.xstream.InitializationException: Unable to
> > > create an XmlPullParser with feature
> > > http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> > > at
> com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> > > at
> > >
>
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> > > at
> > >
> edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> > > at
> edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> > > Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> > > is not supported
> > > at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> > > at
> > >
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> > > ... 6 more
> > >
> > >
> > >
> > >
> > > --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> > > wrote:
> > >
> > >> fibremux999 wrote:
> > >>
> > >>> Hi,
> > >>>
> > >>> I'm working with some software that uses xpp3 as its parser.
> However
> > >>> the software as it is designed doesn't allow me to have access
> to the
> > >>> parser factory.
> > >>>
> > >>> Since I don't have access to the parser factory, I'm unable to
call
> > >>> the setFeature() method on the factoy. Specifically I need to
> enable
> > >>> the FEATURE_PROCESS_DOCDECL
> > >>> (http://xmlpull.org/v1/doc/features.html#process-docdecl)
feature.
> > >>>
> > >>> Am I able to enable factory features by setting a system
> property, or
> > >>> can that only be done via the setFeature() method itself?
> > >>>
> > >>> I've attempted to set a variety of system properties, none of
which
> > >>> seem to work.
> > >>>
> > >>>
> > >> if you know the parser implementation class name you can create it
> > >> directly without factory and call setFeature on that parser
(that is
> > >> what factory is typically doing)
> > >>
> > >> HTH,
> > >>
> > >> alek
> > >>
> > >> --
> > >> The best way to predict the future is to invent it - Alan Kay
> > >>
> > >>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > --
> > The best way to predict the future is to invent it - Alan Kay
> >
>
Ok,
Duh. I read that DOCDECL is always enabled for xni2xml. Sorry for
making so much noise.
Ok, so I have entities defined in my document declaration that aren't
being resolved. I'm not sure yet if it is an parser issue or an
XStream issue.
Am looking deeper.
Elliot
--- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@...>
wrote:
>
> XPP3 does nto support DOCDECL feature instead pull from CVS xni2xmlpull
> and use it instead (assuming sourceforge cvs works ...)
>
> http://sourceforge.net/projects/xni2xmlpull/
>
> let me know if you have problems with it (if it works ok i may just make
> an official release of xni2xmkpull)
>
> best,
>
> alek
>
> fibremux999 wrote:
> > Ack. Ok, for the record I'm working with XStream 1.1.3. My apologies
> > if this is really an XStream question (flame away!)
> >
> > XStream has three main interfaces:
> > HierarchicalStreamDriver
> > HierarchicalStreamReader
> > HierarchicalStreamWriter
> >
> > ... and there is a corresponding Xpp implementation for each of those
> > interfaces.
> >
> > What I've done is extended the Xpp driver and reader implementations
> > (I don't care about writer) and I've overridden certain methods to
> > enable the DOCDECL feature.
> >
> > However, I'm getting this stack trace [0] when I attempt to set the
> > feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> > 1.1.3.3 from the IBiblio maven repository
> > (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
> >
> > The exception puzzles me because it originates from
> > org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> > an incorrect or older version of Xpp?
> >
> > Thanks for your guidance to someone who knows enough to be dangerous,
> > Elliot
> >
> > [0] Exception below:
> >
> > Exception in thread "main"
> > edu.jhu.library.scratch.xstream.InitializationException: Unable to
> > create an XmlPullParser with feature
> > http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> > at
com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> > at
> >
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> > at
> >
edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> > at
edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> > Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> > is not supported
> > at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> > ... 6 more
> >
> >
> >
> >
> > --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> > wrote:
> >
> >> fibremux999 wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm working with some software that uses xpp3 as its parser.
However
> >>> the software as it is designed doesn't allow me to have access
to the
> >>> parser factory.
> >>>
> >>> Since I don't have access to the parser factory, I'm unable to call
> >>> the setFeature() method on the factoy. Specifically I need to
enable
> >>> the FEATURE_PROCESS_DOCDECL
> >>> (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
> >>>
> >>> Am I able to enable factory features by setting a system
property, or
> >>> can that only be done via the setFeature() method itself?
> >>>
> >>> I've attempted to set a variety of system properties, none of which
> >>> seem to work.
> >>>
> >>>
> >> if you know the parser implementation class name you can create it
> >> directly without factory and call setFeature on that parser (that is
> >> what factory is typically doing)
> >>
> >> HTH,
> >>
> >> alek
> >>
> >> --
> >> The best way to predict the future is to invent it - Alan Kay
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
Hi Alek,
--- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@...>
wrote:
>
> XPP3 does nto support DOCDECL feature instead pull from CVS xni2xmlpull
> and use it instead (assuming sourceforge cvs works ...)
>
> http://sourceforge.net/projects/xni2xmlpull/
>
> let me know if you have problems with it (if it works ok i may just make
> an official release of xni2xmkpull)
I wrote an XNI driver and reader implementation for XStream, but when
I attempted to set the DOCDECL feature it crashed and burned. I'm
working with the HEAD of xni2xml.
Indeed, I checked (version 1.5) the setFeature() of X2Parser and the
DOCDECL feature doesn't seem to be supported.
Thoughts?
Thanks much,
Elliot
>
> best,
>
> alek
>
> fibremux999 wrote:
> > Ack. Ok, for the record I'm working with XStream 1.1.3. My apologies
> > if this is really an XStream question (flame away!)
> >
> > XStream has three main interfaces:
> > HierarchicalStreamDriver
> > HierarchicalStreamReader
> > HierarchicalStreamWriter
> >
> > ... and there is a corresponding Xpp implementation for each of those
> > interfaces.
> >
> > What I've done is extended the Xpp driver and reader implementations
> > (I don't care about writer) and I've overridden certain methods to
> > enable the DOCDECL feature.
> >
> > However, I'm getting this stack trace [0] when I attempt to set the
> > feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> > 1.1.3.3 from the IBiblio maven repository
> > (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
> >
> > The exception puzzles me because it originates from
> > org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> > an incorrect or older version of Xpp?
> >
> > Thanks for your guidance to someone who knows enough to be dangerous,
> > Elliot
> >
> > [0] Exception below:
> >
> > Exception in thread "main"
> > edu.jhu.library.scratch.xstream.InitializationException: Unable to
> > create an XmlPullParser with feature
> > http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> > at
com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> > at
> >
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> > at
> >
edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> > at
edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> > Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> > is not supported
> > at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> > ... 6 more
> >
> >
> >
> >
> > --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> > wrote:
> >
> >> fibremux999 wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm working with some software that uses xpp3 as its parser.
However
> >>> the software as it is designed doesn't allow me to have access
to the
> >>> parser factory.
> >>>
> >>> Since I don't have access to the parser factory, I'm unable to call
> >>> the setFeature() method on the factoy. Specifically I need to
enable
> >>> the FEATURE_PROCESS_DOCDECL
> >>> (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
> >>>
> >>> Am I able to enable factory features by setting a system
property, or
> >>> can that only be done via the setFeature() method itself?
> >>>
> >>> I've attempted to set a variety of system properties, none of which
> >>> seem to work.
> >>>
> >>>
> >> if you know the parser implementation class name you can create it
> >> directly without factory and call setFeature on that parser (that is
> >> what factory is typically doing)
> >>
> >> HTH,
> >>
> >> alek
> >>
> >> --
> >> The best way to predict the future is to invent it - Alan Kay
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
--- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@...>
wrote:
>
> XPP3 does nto support DOCDECL feature instead pull from CVS xni2xmlpull
Apparently I don't know enough to read the implementation feature
matrix at http://www.xmlpull.org/impls.shtml :)
> and use it instead (assuming sourceforge cvs works ...)
>
> http://sourceforge.net/projects/xni2xmlpull/
Ok, I'm not sure how much work needs to be done to implement the
XStream interfaces, but I have checked it out of CVS and I'll give it
the college try :)
> let me know if you have problems with it (if it works ok i may just make
> an official release of xni2xmkpull)
I'll definitly respond with some feedback.
Thanks Alek for help,
Elliot
>
> fibremux999 wrote:
> > Ack. Ok, for the record I'm working with XStream 1.1.3. My apologies
> > if this is really an XStream question (flame away!)
> >
> > XStream has three main interfaces:
> > HierarchicalStreamDriver
> > HierarchicalStreamReader
> > HierarchicalStreamWriter
> >
> > ... and there is a corresponding Xpp implementation for each of those
> > interfaces.
> >
> > What I've done is extended the Xpp driver and reader implementations
> > (I don't care about writer) and I've overridden certain methods to
> > enable the DOCDECL feature.
> >
> > However, I'm getting this stack trace [0] when I attempt to set the
> > feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> > 1.1.3.3 from the IBiblio maven repository
> > (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
> >
> > The exception puzzles me because it originates from
> > org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> > an incorrect or older version of Xpp?
> >
> > Thanks for your guidance to someone who knows enough to be dangerous,
> > Elliot
> >
> > [0] Exception below:
> >
> > Exception in thread "main"
> > edu.jhu.library.scratch.xstream.InitializationException: Unable to
> > create an XmlPullParser with feature
> > http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> > at
com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> > at
> >
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> > at
> >
edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> > at
edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> > Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> > is not supported
> > at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> > at
> >
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> > ... 6 more
> >
> >
> >
> >
> > --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@>
> > wrote:
> >
> >> fibremux999 wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm working with some software that uses xpp3 as its parser.
However
> >>> the software as it is designed doesn't allow me to have access
to the
> >>> parser factory.
> >>>
> >>> Since I don't have access to the parser factory, I'm unable to call
> >>> the setFeature() method on the factoy. Specifically I need to
enable
> >>> the FEATURE_PROCESS_DOCDECL
> >>> (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
> >>>
> >>> Am I able to enable factory features by setting a system
property, or
> >>> can that only be done via the setFeature() method itself?
> >>>
> >>> I've attempted to set a variety of system properties, none of which
> >>> seem to work.
> >>>
> >>>
> >> if you know the parser implementation class name you can create it
> >> directly without factory and call setFeature on that parser (that is
> >> what factory is typically doing)
> >>
> >> HTH,
> >>
> >> alek
> >>
> >> --
> >> The best way to predict the future is to invent it - Alan Kay
> >>
> >>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
XPP3 does nto support DOCDECL feature instead pull from CVS xni2xmlpull
and use it instead (assuming sourceforge cvs works ...)
http://sourceforge.net/projects/xni2xmlpull/
let me know if you have problems with it (if it works ok i may just make
an official release of xni2xmkpull)
best,
alek
fibremux999 wrote:
> Ack. Ok, for the record I'm working with XStream 1.1.3. My apologies
> if this is really an XStream question (flame away!)
>
> XStream has three main interfaces:
> HierarchicalStreamDriver
> HierarchicalStreamReader
> HierarchicalStreamWriter
>
> ... and there is a corresponding Xpp implementation for each of those
> interfaces.
>
> What I've done is extended the Xpp driver and reader implementations
> (I don't care about writer) and I've overridden certain methods to
> enable the DOCDECL feature.
>
> However, I'm getting this stack trace [0] when I attempt to set the
> feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
> 1.1.3.3 from the IBiblio maven repository
> (http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
>
> The exception puzzles me because it originates from
> org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
> an incorrect or older version of Xpp?
>
> Thanks for your guidance to someone who knows enough to be dangerous,
> Elliot
>
> [0] Exception below:
>
> Exception in thread "main"
> edu.jhu.library.scratch.xstream.InitializationException: Unable to
> create an XmlPullParser with feature
> http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
> at
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
> at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
> at
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
> at
>
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
> at
> com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
> at
> edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
> at edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
> Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
> is not supported
> at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
> at
>
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
> ... 6 more
>
>
>
>
> --- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@...>
> wrote:
>
>> fibremux999 wrote:
>>
>>> Hi,
>>>
>>> I'm working with some software that uses xpp3 as its parser. However
>>> the software as it is designed doesn't allow me to have access to the
>>> parser factory.
>>>
>>> Since I don't have access to the parser factory, I'm unable to call
>>> the setFeature() method on the factoy. Specifically I need to enable
>>> the FEATURE_PROCESS_DOCDECL
>>> (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
>>>
>>> Am I able to enable factory features by setting a system property, or
>>> can that only be done via the setFeature() method itself?
>>>
>>> I've attempted to set a variety of system properties, none of which
>>> seem to work.
>>>
>>>
>> if you know the parser implementation class name you can create it
>> directly without factory and call setFeature on that parser (that is
>> what factory is typically doing)
>>
>> HTH,
>>
>> alek
>>
>> --
>> The best way to predict the future is to invent it - Alan Kay
>>
>>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay
Ack. Ok, for the record I'm working with XStream 1.1.3. My apologies
if this is really an XStream question (flame away!)
XStream has three main interfaces:
HierarchicalStreamDriver
HierarchicalStreamReader
HierarchicalStreamWriter
... and there is a corresponding Xpp implementation for each of those
interfaces.
What I've done is extended the Xpp driver and reader implementations
(I don't care about writer) and I've overridden certain methods to
enable the DOCDECL feature.
However, I'm getting this stack trace [0] when I attempt to set the
feature, and I'm not sure why. I am using XStream 1.1.3 and XPP
1.1.3.3 from the IBiblio maven repository
(http://www.ibiblio.org/maven2/xpp3/xpp3/1.1.3.3/xpp3-1.1.3.3.jar).
The exception puzzles me because it originates from
org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453). Am I using
an incorrect or older version of Xpp?
Thanks for your guidance to someone who knows enough to be dangerous,
Elliot
[0] Exception below:
Exception in thread "main"
edu.jhu.library.scratch.xstream.InitializationException: Unable to
create an XmlPullParser with feature
http://xmlpull.org/v1/doc/features.html#process-docdecl enabled.
at
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:35)
at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:25)
at
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.<init>(XppDocDeclEnabled\
Reader.java:18)
at
edu.jhu.library.scratch.xstream.XppDocDeclDriver.createReader(XppDocDeclDriver.j\
ava:22)
at
com.thoughtworks.xstream.XStream.createObjectInputStream(XStream.java:783)
at
edu.jhu.library.scratch.xstream.EresXstream.<init>(EresXstream.java:105)
at edu.jhu.library.scratch.xstream.EresXstream.main(EresXstream.java:152)
Caused by: org.xmlpull.v1.XmlPullParserException: processing DOCDECL
is not supported
at org.xmlpull.mxp1.MXParser.setFeature(MXParser.java:453)
at
edu.jhu.library.scratch.xstream.XppDocDeclEnabledReader.createParser(XppDocDeclE\
nabledReader.java:31)
... 6 more
--- In xmlpull-user@yahoogroups.com, Aleksander Slominski <aslom@...>
wrote:
>
> fibremux999 wrote:
> > Hi,
> >
> > I'm working with some software that uses xpp3 as its parser. However
> > the software as it is designed doesn't allow me to have access to the
> > parser factory.
> >
> > Since I don't have access to the parser factory, I'm unable to call
> > the setFeature() method on the factoy. Specifically I need to enable
> > the FEATURE_PROCESS_DOCDECL
> > (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
> >
> > Am I able to enable factory features by setting a system property, or
> > can that only be done via the setFeature() method itself?
> >
> > I've attempted to set a variety of system properties, none of which
> > seem to work.
> >
> if you know the parser implementation class name you can create it
> directly without factory and call setFeature on that parser (that is
> what factory is typically doing)
>
> HTH,
>
> alek
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
fibremux999 wrote:
> Hi,
>
> I'm working with some software that uses xpp3 as its parser. However
> the software as it is designed doesn't allow me to have access to the
> parser factory.
>
> Since I don't have access to the parser factory, I'm unable to call
> the setFeature() method on the factoy. Specifically I need to enable
> the FEATURE_PROCESS_DOCDECL
> (http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
>
> Am I able to enable factory features by setting a system property, or
> can that only be done via the setFeature() method itself?
>
> I've attempted to set a variety of system properties, none of which
> seem to work.
>
if you know the parser implementation class name you can create it
directly without factory and call setFeature on that parser (that is
what factory is typically doing)
HTH,
alek
--
The best way to predict the future is to invent it - Alan Kay
Hi,
I'm working with some software that uses xpp3 as its parser. However
the software as it is designed doesn't allow me to have access to the
parser factory.
Since I don't have access to the parser factory, I'm unable to call
the setFeature() method on the factoy. Specifically I need to enable
the FEATURE_PROCESS_DOCDECL
(http://xmlpull.org/v1/doc/features.html#process-docdecl) feature.
Am I able to enable factory features by setting a system property, or
can that only be done via the setFeature() method itself?
I've attempted to set a variety of system properties, none of which
seem to work.
Thanks for your feedback!
Elliot
Hi,
> i think what Peter asked for is for API that allows to parse multiple
> nio inputs in the same time efficiently by using selector like API - as
> far as i can tell Javolution XPP is exactly like XmlPull v1 but uses
> CharSequence? are there any other changes?
Yes: XmlPullParserImpl.setInput(java.nio.ByteBuffer)
It is part of Javolution xpp implementation (but ot could be moved to the
interface).
It allows the xpp parsers to use nio byte buffer directly (non-blocking).
For example to parse udp xml messages (note: the udp message must contain
well-formed xml elements with end-tag).
Best regards,
Jean-Marie.
> Jean-Marie Dautelle wrote:
> > You might want to look at Javolution XPP-like parser supporting NIO
> > directly:
> > http://javolution.org/api/javolution/xml/pull/XmlPullParserImpl.html
> >
> > Best regards,
> > Jean-Marie (Javolution project owner).
> >
> > PS: XPP-Like because it uses CharSequence instead of Strings to avoid
> > creating objects dynamically (faster).
> >
> hi Jean-Marie,
>
> i think what Peter asked for is for API that allows to parse multiple
> nio inputs in the same time efficiently by using selector like API - as
> far as i can tell Javolution XPP is exactly like XmlPull v1 but uses
> CharSequence? are there any other changes?
>
> thanks,
>
> alek
> >
> >
> >> Hi all,
> >>
> >> Are there any thoughts about updating the API to take advantage of
> the
> >> java.nio package, and/or read data in a non-blocking mode in general?
> >>
> >> This would require a new return token to signal back that the parser
> >> has temporarily ran out of bytes to parse the next entity (e.g.,
> >> RETRY_LATER). The whole point would then be the possibility to read
> >> many streams in parallel using one thread...
> >>
> >> Regards,
> >> /Peter
> >>
> >>
> >>
> >>
> >>
> >> YAHOO! GROUPS LINKS
> >> Visit your group "xmlpull-user" on the web.
> >> To unsubscribe from this group, send an email to:
> >> xmlpull-user-unsubscribe@yahoogroups.com
> >> Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
> >>
> >>
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
>
> YAHOO! GROUPS LINKS
> Visit your group "xmlpull-user" on the web.
> To unsubscribe from this group, send an email to:
> xmlpull-user-unsubscribe@yahoogroups.com
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
Jean-Marie Dautelle wrote:
> You might want to look at Javolution XPP-like parser supporting NIO
> directly:
> http://javolution.org/api/javolution/xml/pull/XmlPullParserImpl.html
>
> Best regards,
> Jean-Marie (Javolution project owner).
>
> PS: XPP-Like because it uses CharSequence instead of Strings to avoid
> creating objects dynamically (faster).
>
hi Jean-Marie,
i think what Peter asked for is for API that allows to parse multiple
nio inputs in the same time efficiently by using selector like API - as
far as i can tell Javolution XPP is exactly like XmlPull v1 but uses
CharSequence? are there any other changes?
thanks,
alek
>
>
>> Hi all,
>>
>> Are there any thoughts about updating the API to take advantage of the
>> java.nio package, and/or read data in a non-blocking mode in general?
>>
>> This would require a new return token to signal back that the parser
>> has temporarily ran out of bytes to parse the next entity (e.g.,
>> RETRY_LATER). The whole point would then be the possibility to read
>> many streams in parallel using one thread...
>>
>> Regards,
>> /Peter
>>
>>
>>
>>
>>
>> YAHOO! GROUPS LINKS
>> Visit your group "xmlpull-user" on the web.
>> To unsubscribe from this group, send an email to:
>> xmlpull-user-unsubscribe@yahoogroups.com
>> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>>
>>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay
Hi,
You might want to look at Javolution XPP-like parser supporting NIO
directly:
http://javolution.org/api/javolution/xml/pull/XmlPullParserImpl.html
Best regards,
Jean-Marie (Javolution project owner).
PS: XPP-Like because it uses CharSequence instead of Strings to avoid
creating objects dynamically (faster).
> Hi all,
>
> Are there any thoughts about updating the API to take advantage of the
> java.nio package, and/or read data in a non-blocking mode in general?
>
> This would require a new return token to signal back that the parser
> has temporarily ran out of bytes to parse the next entity (e.g.,
> RETRY_LATER). The whole point would then be the possibility to read
> many streams in parallel using one thread...
>
> Regards,
> /Peter
>
>
>
>
>
> YAHOO! GROUPS LINKS
> Visit your group "xmlpull-user" on the web.
> To unsubscribe from this group, send an email to:
> xmlpull-user-unsubscribe@yahoogroups.com
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
peter.loborg wrote:
> Hi all,
>
> Are there any thoughts about updating the API to take advantage of the
> java.nio package, and/or read data in a non-blocking mode in general?
>
> This would require a new return token to signal back that the parser
> has temporarily ran out of bytes to parse the next entity (e.g.,
> RETRY_LATER). The whole point would then be the possibility to read
> many streams in parallel using one thread...
>
hi Peter,
this would be very different API from XmlPull V1 however if you have a
proposed API and implementation I see no reason why xmlpull.org website
should not promote it - i am curious what are the reasons you want it
and if you have examples of programs that could uses such API. the other
interesting trend is that with multi-core CPUs and support for massive
multi-threading Java should be able to take advantage of it and get very
good performance for very large number of threads without nio and such
programming model is much simpler than multiplexing nio streams in one
thread - at least that what it seams to me ...
best,
alek
--
The best way to predict the future is to invent it - Alan Kay
Hi all,
Are there any thoughts about updating the API to take advantage of the
java.nio package, and/or read data in a non-blocking mode in general?
This would require a new return token to signal back that the parser
has temporarily ran out of bytes to parse the next entity (e.g.,
RETRY_LATER). The whole point would then be the possibility to read
many streams in parallel using one thread...
Regards,
/Peter
ibn_elromeya wrote:
> Hello,
>
> I am trying to parse the following XML chunk to find the 'value' of
> node and 'action' :
>
> <iq type='set' to='responder@domain' id='exec1'>
> <command xmlns='http://jabber.org/protocol/commands'
> node='list'
> action='execute'/>
> </iq>
>
> I have written the following code to accomplish this:
>
> if (eventType == XmlPullParser.START_TAG) {
> if (parser.getName().equals("command")) {
> action = parser.getAttributeValue("","action");
> node = parser.getAttributeValue("","node");
> }
> }
>
> However, I have realized that the second IF statement is never
> evaluated as TRUE. So, I changed the START_TAG to END_TAG, but i get
> the following error:
>
> java.lang.IndexOutOfBoundsException: only START_TAG can have
> attributes END_TAG seen
>
> Any help or guidance would be appreciated.
>
hi Ibn,
please _always_ post the whole code and exactly what is the parser impl
used so problems yuou see can be pinpointed and reproduced ...
i tried with xpp3 and using ExampleST.java (see below) i got this
parser implementation class is class org.xmlpull.mxp1.MXParserCachingStrings
Start document
Start tag iq
Text
Start tag command
action = execute
node = list
End tag command
Text
End tag iq
alek
import java.io.IOException;
import java.io.StringReader;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
public class ExampleST {
final static String SAMPLE_XML =
"<iq type='set' to='responder@domain' id='exec1'>\n"+
"<command xmlns='http://jabber.org/protocol/commands'\n"+
"node='list'\n"+
"action='execute'/>\n"+
"</iq>\n"+
"";
public static void main (String args[])
throws XmlPullParserException, IOException
{
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(
//System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null);
"org.xmlpull.mxp1.MXParserFactory", null);
factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
XmlPullParser pp = factory.newPullParser();
System.out.println("parser implementation class is "+pp.getClass());
pp.setInput(new StringReader(SAMPLE_XML));
int eventType = pp.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if(eventType == XmlPullParser.START_DOCUMENT) {
System.out.println("Start document");
} else if(eventType == XmlPullParser.END_DOCUMENT) {
System.out.println("End document");
} else if(eventType == XmlPullParser.START_TAG) {
System.out.println("Start tag "+pp.getName());
if (pp.getName().equals("command")) {
System.out.println(" action =
"+pp.getAttributeValue("","action"));
System.out.println(" node =
"+pp.getAttributeValue("","node"));
}
} else if(eventType == XmlPullParser.END_TAG) {
System.out.println("End tag "+pp.getName());
} else if(eventType == XmlPullParser.TEXT) {
System.out.println("Text "+pp.getText());
}
eventType = pp.next();
}
}
}
--
The best way to predict the future is to invent it - Alan Kay
Hello,
I am trying to parse the following XML chunk to find the 'value' of
node and 'action' :
<iq type='set' to='responder@domain' id='exec1'>
<command xmlns='http://jabber.org/protocol/commands'
node='list'
action='execute'/>
</iq>
I have written the following code to accomplish this:
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("command")) {
action = parser.getAttributeValue("","action");
node = parser.getAttributeValue("","node");
}
}
However, I have realized that the second IF statement is never
evaluated as TRUE. So, I changed the START_TAG to END_TAG, but i get
the following error:
java.lang.IndexOutOfBoundsException: only START_TAG can have
attributes END_TAG seen
Any help or guidance would be appreciated.
Thanks
Regards,
Ibn Elromeya
hi stefan
here is the code that i'm using for accessing the datas from the xml
file using KXML2.
try{
InputStreamReader reader = new InputStreamReader(nIS);
KXmlParser parser = new KXmlParser();
parser.setInput(reader);
while(true){-------------------------------------(1)
int eventType = parser.nextTag();
if(eventType == XmlPullParser.START_TAG) {
String tag = parser.getName();
if("poll".equals(tag)) {
for(int i=0; i < parser.getAttributeCount(); i++){
String attr = parser.getAttributeValue(i);
if (parser.getAttributeName(i).equals("pollid")){
vPollID.addElement(attr);
}else if (parser.getAttributeName (i).
equals"pollquestion")){
vPollQuestion.addElement(attr);
}
}
System.out.println("getPositionDescription() "
+parser.getPositionDescription());
while(true) {----------------------------------------(2)
int eventTyppe = parser.next();
System.out.println("parser.nextTag() "+parser.getName());
if(eventType == XmlPullParser.START_TAG) {
for(int i=0; i < parser.getAttributeCount(); i++){
String attr = parser.getAttributeValue(i);
if (parser.getAttributeName(i).equals("answerid")){
vPollAnswerID.addElement(attr);
}else if (parser.getAttributeName(i).equals("answer")){
vPollAnswer.addElement(attr);
}else if (parser.getAttributeName(i).equals("vote")){
vPollVote.addElement(attr);
}
}
}else if(eventType == XmlPullParser.END_TAG) {
break;
}
}
}else if(eventType == XmlPullParser.END_TAG) {
break;
}
}else if(eventType == XmlPullParser.END_TAG) {
break;
}
}
}catch(Exception e){
System.out.println("error in poll parsing");
}
in while 1 trying to access the poll tag elements and also able to
access but in while "2" trying to access the pollanswer attributes,
but its unable to do that.
please suggest.
thanks
rupak
--- In xmlpull-user@yahoogroups.com, Stefan Haustein <haustein@...>
wrote:
>
> Hi Rupak,
>
> there are some missing quotes in the pollanswer element. Please
change
>
> vote=75
>
> to
>
> vote="75"
>
> if that does not help, please send an executable piece of source
code
> that allows us to reproduce the problem.
>
> Best regards,
> Stefan
>
>
> rupak samant wrote:
>
> > Hi Aleksander
> >
> > here is the XML file that i want to parse.
> >
> > <?xml version='1.0' encoding='iso-8859-1'?>
> > <data>
> > <poll pollid="1" pollquestion="whats ur name">
> > <pollanswer answerid="1" answer="rupak" vote=75></pollanswer>
> > </poll>
> > </data>
> >
> > from this file i want to extract the data.ans i was also succeded
upto
> > the "poll" tag. but unable to parse the pollanswer tag. can u say
> > whether we can access the child elements using KXML2 ?
> >
> > thanks in advance.
> >
> > rupak
> >
> > */xmlpull-user@yahoogroups.com/* wrote:
> >
> > There are 2 messages in this issue.
> >
> > Topics in this digest:
> >
> > 1. problem in access! ing sibling elements using KXML2
> > From: "rupak"
> > 2. Re: problem in accessing sibling elements using KXML2
> > From: Aleksander Slominski
> >
> >
> >
______________________________________________________________________
__
> >
______________________________________________________________________
__
> >
> > Message: 1
> > Date: Fri, 03 Mar 2006 10:12:47 -0000
> > From: "rupak"
> > Subject: problem in accessing sibling elements using KXML2
> >
> > hello everybody,
> >
> > how to parse the child element from the XML file by using
KXML2.
> >
> > please help me out if anyone know the matter.
> >
> > thanks in advance
> >
> >
> > rupak
> >
> >
> >
> >
> >
> >
______________________________________________________________________
__
> >
______________________________________________________________________
__
> >
> > Message: 2
> > Date: Fri, 03 Mar 2006 11:39:14 -0500
> > From: Aleksander Slominski
> > S! ubject: Re: problem in accessing sibling elements using
KXML2
> >
> > rupak wrote:
> > > hello everybody,
> > >
> > > how to parse the child element from the XML file by using
KXML2.
> > >
> > > please help me out if anyone know the matter.
> > >
> > > thanks in advance
> > >
> > >
> > i have no idea what is the problem ... could you give actual
example,
> > show what happens and describe what is expected results.
> >
> > best,
> >
> > alek
> >
> > --
> > The best way to predict the future is to invent it - Alan Kay
> >
> >
> >
> >
______________________________________________________________________
__
> >
______________________________________________________________________
__
> >
> >
> >
> > --------------------------------------------------------------
----------
> > Yahoo! Groups Links
> >
> >
> >
> >
> > --------------------------------------------------------------
----------
> >
> >
> >
> >
> >
> > Send instant messages to your online friends
http://uk.messenger.yahoo.com
> >
> > ------------------------------------------------------------------
------
> > YAHOO! GROUPS LINKS
> >
> > * Visit your group "xmlpull-user
> > <http://groups.yahoo.com/group/xmlpull-user>" on the web.
> >
> > * To unsubscribe from this group, send an email to:
> > xmlpull-user-unsubscribe@yahoogroups.com
> > <mailto:xmlpull-user-unsubscribe@yahoogroups.com?
subject=Unsubscribe>
> >
> > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/>.
> >
> >
> > ------------------------------------------------------------------
------
> >
>
Hi Rupak,
there are some missing quotes in the pollanswer element. Please change
vote=75
to
vote="75"
if that does not help, please send an executable piece of source code
that allows us to reproduce the problem.
Best regards,
Stefan
rupak samant wrote:
> Hi Aleksander
>
> here is the XML file that i want to parse.
>
> <?xml version='1.0' encoding='iso-8859-1'?>
> <data>
> <poll pollid="1" pollquestion="whats ur name">
> <pollanswer answerid="1" answer="rupak" vote=75></pollanswer>
> </poll>
> </data>
>
> from this file i want to extract the data.ans i was also succeded upto
> the "poll" tag. but unable to parse the pollanswer tag. can u say
> whether we can access the child elements using KXML2 ?
>
> thanks in advance.
>
> rupak
>
> */xmlpull-user@yahoogroups.com/* wrote:
>
> There are 2 messages in this issue.
>
> Topics in this digest:
>
> 1. problem in access! ing sibling elements using KXML2
> From: "rupak"
> 2. Re: problem in accessing sibling elements using KXML2
> From: Aleksander Slominski
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 1
> Date: Fri, 03 Mar 2006 10:12:47 -0000
> From: "rupak"
> Subject: problem in accessing sibling elements using KXML2
>
> hello everybody,
>
> how to parse the child element from the XML file by using KXML2.
>
> please help me out if anyone know the matter.
>
> thanks in advance
>
>
> rupak
>
>
>
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 2
> Date: Fri, 03 Mar 2006 11:39:14 -0500
> From: Aleksander Slominski
> S! ubject: Re: problem in accessing sibling elements using KXML2
>
> rupak wrote:
> > hello everybody,
> >
> > how to parse the child element from the XML file by using KXML2.
> >
> > please help me out if anyone know the matter.
> >
> > thanks in advance
> >
> >
> i have no idea what is the problem ... could you give actual example,
> show what happens and describe what is expected results.
>
> best,
>
> alek
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
>
>
> ------------------------------------------------------------------------
> Yahoo! Groups Links
>
>
>
>
> ------------------------------------------------------------------------
>
>
>
>
>
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
> * Visit your group "xmlpull-user
> <http://groups.yahoo.com/group/xmlpull-user>" on the web.
>
> * To unsubscribe from this group, send an email to:
> xmlpull-user-unsubscribe@yahoogroups.com
> <mailto:xmlpull-user-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>
rupak samant wrote:
> here is the XML file that i want to parse.
>
> <?xml version='1.0' encoding='iso-8859-1'?>
> <data>
> <poll pollid="1" pollquestion="whats ur name">
> <pollanswer answerid="1" answer="rupak" vote=75></pollanswer>
> </poll>
> </data>
>
> from this file i want to extract the data.ans i was also succeded upto
> the "poll" tag. but unable to parse the pollanswer tag. can u say
> whether we can access the child elements using KXML2 ?
XML looks OK. what error did you get? what was Java code you used to
parse and exact verion of kXML2 (your CLASSPATH)? how to reproduce it?
best,
alek
>
>
> */xmlpull-user@yahoogroups.com/* wrote:
>
> There are 2 messages in this issue.
>
> Topics in this digest:
>
> 1. problem in access! ing sibling elements using KXML2
> From: "rupak"
> 2. Re: problem in accessing sibling elements using KXML2
> From: Aleksander Slominski
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 1
> Date: Fri, 03 Mar 2006 10:12:47 -0000
> From: "rupak"
> Subject: problem in accessing sibling elements using KXML2
>
> hello everybody,
>
> how to parse the child element from the XML file by using KXML2.
>
> please help me out if anyone know the matter.
>
> thanks in advance
>
>
> rupak
>
>
>
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
> Message: 2
> Date: Fri, 03 Mar 2006 11:39:14 -0500
> From: Aleksander Slominski
> S! ubject: Re: problem in accessing sibling elements using KXML2
>
> rupak wrote:
> > hello everybody,
> >
> > how to parse the child element from the XML file by using KXML2.
> >
> > please help me out if anyone know the matter.
> >
> > thanks in advance
> >
> >
> i have no idea what is the problem ... could you give actual example,
> show what happens and describe what is expected results.
>
> best,
>
> alek
>
> --
> The best way to predict the future is to invent it - Alan Kay
>
>
>
> ________________________________________________________________________
> ________________________________________________________________________
>
>
>
> ------------------------------------------------------------------------
> Yahoo! Groups Links
>
>
>
>
> ------------------------------------------------------------------------
>
>
>
>
>
> Send instant messages to your online friends
> http://uk.messenger.yahoo.com
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
> * Visit your group "xmlpull-user
> <http://groups.yahoo.com/group/xmlpull-user>" on the web.
>
> * To unsubscribe from this group, send an email to:
> xmlpull-user-unsubscribe@yahoogroups.com
> <mailto:xmlpull-user-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>
--
The best way to predict the future is to invent it - Alan Kay
from this file i want to extract the data.ans i was also succeded upto the "poll" tag. but unable to parse the pollanswer tag. can u say whether we can access the child elements using KXML2 ?
thanks in advance.
rupak
xmlpull-user@yahoogroups.com wrote:
There are 2 messages in this issue.
Topics in this digest:
1. problem in accessing
sibling elements using KXML2 From: "rupak" 2. Re: problem in accessing sibling elements using KXML2 From: Aleksander Slominski
Message: 2 Date: Fri, 03 Mar 2006 11:39:14 -0500 From: Aleksander Slominski Subject:
Re: problem in accessing sibling elements using KXML2
rupak wrote: > hello everybody, > > how to parse the child element from the XML file by using KXML2. > > please help me out if anyone know the matter. > > thanks in advance > > i have no idea what is the problem ... could you give actual example, show what happens and describe what is expected results.
best,
alek
-- The best way to predict the future is to invent it - Alan Kay
rupak wrote:
> hello everybody,
>
> how to parse the child element from the XML file by using KXML2.
>
> please help me out if anyone know the matter.
>
> thanks in advance
>
>
i have no idea what is the problem ... could you give actual example,
show what happens and describe what is expected results.
best,
alek
--
The best way to predict the future is to invent it - Alan Kay
hello everybody,
how to parse the child element from the XML file by using KXML2.
please help me out if anyone know the matter.
thanks in advance
rupak
jkiwzztn wrote:
>Hi, I was thinking about trying the Pull parsing so I wrote a simple
>app but I keep getting the error message saying that no valid class
>found ( the message is shown below) What did I do wrong?
>
>Exception in thread "main" org.xmlpull.v1.XmlPullParserException: No
>valid parse
>r classes found in parameter classNames to newInstance() that
>contained 'org.xml
>pull.v1.XmlPullParserFactory'
> at org.xmlpull.v1.XmlPullParserFactory.newPullParser
>(XmlPullParserFactor
>y.java:175)
> at tryPull.main(tryPull.java:14)
>
>
>Below is the app code
>=======================
>import java.io.*;
>
>import org.xmlpull.v1.XmlPullParser;
>import org.xmlpull.v1.XmlPullParserException;
>import org.xmlpull.v1.XmlPullParserFactory;
>
>class tryPull {
> public static void main(String argv[]) throws Exception
> {
> XmlPullParserFactory factory =
>XmlPullParserFactory.newInstance(
> "org.xmlpull.v1.XmlPullParserFactory", null);
>
>
please follow online docs
(http://www.xmlpull.org/v1/download/unpacked/doc/quick_intro.html) and
make sure to use a constant not actual class name then make sure you
have a parser that implements XmlPull API on your classpath. for example
download xpp3-1.1.3.4.O.jar from [1] and put on your CLASSPATH and it
should work
HTH,
alek
[1] http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/
> factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,
>true);
>
> XmlPullParser xpp = factory.newPullParser();
> }
>}
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
--
The best way to predict the future is to invent it - Alan Kay
Hi, I was thinking about trying the Pull parsing so I wrote a simple
app but I keep getting the error message saying that no valid class
found ( the message is shown below) What did I do wrong?
Exception in thread "main" org.xmlpull.v1.XmlPullParserException: No
valid parse
r classes found in parameter classNames to newInstance() that
contained 'org.xml
pull.v1.XmlPullParserFactory'
at org.xmlpull.v1.XmlPullParserFactory.newPullParser
(XmlPullParserFactor
y.java:175)
at tryPull.main(tryPull.java:14)
Below is the app code
=======================
import java.io.*;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
class tryPull {
public static void main(String argv[]) throws Exception
{
XmlPullParserFactory factory =
XmlPullParserFactory.newInstance(
"org.xmlpull.v1.XmlPullParserFactory", null);
factory.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,
true);
XmlPullParser xpp = factory.newPullParser();
}
}