Search the web
Sign In
New User? Sign Up
xmlpull-user
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 279 - 308 of 308   Newest  |  < Newer  |  Older >  |  Oldest
Messages: Show Message Summaries   (Group by Topic) Sort by Date v  
#308 From: "Aleksander Slominski" <aslom@...>
Date: Wed Dec 12, 2007 6:26 pm
Subject: Re: Stax parsing problem
as10m
Offline Offline
Send Email Send Email
 


On Dec 12, 2007 10:54 AM, xunamua <parthajitbaruah@...> wrote:
Hi,

I hope this post is relevant to this forum.

I'm using Sun's implementation of StAX parser to parse some large xml
files. The file size is about 1.5MB. I'm using the XMLEventReader
interface to parse xmls which consists of many elements like these.
The SCRIPT element contains sql queries which can be very large at times.

The problem I'm facing is that at times the character event returns me
only a part of the text in the SCRIPT element. It happens if there are
spaces and newlines. If the text changes by a single character ( add
or remove a character somewhere ), it starts working fine.

This looks like a general XML parsing problem or it might be something
related to the stax parser. Is there any limit to how many characters
the character event can have at a time ?


Any thoughts on this is highly appreciated.
hi Sam,
 
in contrast o XmlPull API in STAX there is no requirement to retrn all text inside element in one event instead youmay get multiple - just modify your code to expect it.
 
HTH,
 
Alek

<BUILD VERSION="2250.0000">
       <CHANGE NUMBER="0">
           <SCRIPT>
               <![CDATA[
ALTER TABLE INVOICE ALTER COLUMN
   INVOICE_SOLD_TO_PUB_X_REF       NVARCHAR(40) NULL
;
               ]]>
           </SCRIPT>
       </CHANGE>
       <CHANGE NUMBER="1">
       </CHANGE>
   </BUILD>




Yahoo! Groups Links

<*> To visit your group on the web, go to:
   http://groups.yahoo.com/group/xmlpull-user/

<*> Your email settings:
   Individual Email | Traditional

<*> To change settings online go to:
   http://groups.yahoo.com/group/xmlpull-user/join
   (Yahoo! ID required)

<*> To change settings via email:
   mailto:xmlpull-user-digest@yahoogroups.com
   mailto:xmlpull-user-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
   xmlpull-user-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
   http://docs.yahoo.com/info/terms/




--
The best way to predict the future is to invent it - Alan Kay

#307 From: "xunamua" <parthajitbaruah@...>
Date: Wed Dec 12, 2007 3:54 pm
Subject: Stax parsing problem
xunamua
Online Now Online Now
Send Email Send Email
 
Hi,

I hope this post is relevant to this forum.

I'm using Sun's implementation of StAX parser to parse some large xml
files. The file size is about 1.5MB. I'm using the XMLEventReader
interface to parse xmls which consists of many elements like these.
The SCRIPT element contains sql queries which can be very large at times.

The problem I'm facing is that at times the character event returns me
only a part of the text in the SCRIPT element. It happens if there are
spaces and newlines. If the text changes by a single character ( add
or remove a character somewhere ), it starts working fine.

This looks like a general XML parsing problem or it might be something
related to the stax parser. Is there any limit to how many characters
the character event can have at a time ?

Any thoughts on this is highly appreciated.

Thanks

Sam

<BUILD VERSION="2250.0000">
         <CHANGE NUMBER="0">
             <SCRIPT>
                 <![CDATA[
ALTER TABLE INVOICE ALTER COLUMN
     INVOICE_SOLD_TO_PUB_X_REF       NVARCHAR(40) NULL
;
                 ]]>
             </SCRIPT>
         </CHANGE>
         <CHANGE NUMBER="1">
         </CHANGE>
     </BUILD>

#306 From: "lipafrog" <lipafrog@...>
Date: Fri Nov 2, 2007 11:38 am
Subject: Re: XPP3 Namespace Use
lipafrog
Offline Offline
Send Email Send Email
 
Alek,

Thanks for the quick reply!

I believe that XPP3 is set to be namespace aware, as the factory
method I call to give me an XmlInfosetBuilder object sets this flag
to true for me.

Here is a full Java class that I run. I use the latest XPP3 from the
website link: http://www.extreme.indiana.edu/dist/java-
repository/xpp3/distributions/xpp3-1.1.4c_all.zip

I have extended the XPath functions to include the 'matches' and a
half-implementation of the 'index-of', but I have not touched any of
the underlying "base" code, and I have tested with a non-modified
version to verify.

I still think that I am missing something, probably something
obvious like that setNamespaceAware setter, but I just can't seem to
figure out what.

EG


import java.io.StringReader;
import java.util.ArrayList;

import org.xmlpull.v1.builder.XmlDocument;
import org.xmlpull.v1.builder.XmlInfosetBuilder;
import org.xmlpull.v1.builder.xpath.Xb1XPath;

public class Tester {

   /**
    * Tester class for quick tests
    *
    * @param args
    */
   public static void main(String[] args) {
     String xml = "<ns1:A xmlns:ns1=\"http://some.url.org\">" +
         "<ns1:B>" +
           "<ns1:C xyz=\"test\"/>" +
         "</ns1:B>" +
       "</ns1:A>";

     try {
       XmlInfosetBuilder builder = XmlInfosetBuilder.newInstance();

       XmlDocument doc = builder.parseReader(new StringReader(xml));

       Xb1XPath predicateObj = new Xb1XPath("/ns1:A/ns1:B");

       Object retObj = predicateObj.evaluate(doc);

       if (retObj != null) {
         System.out.println(retObj.getClass().getName());

         if (retObj instanceof ArrayList)
           System.out.println(((ArrayList) retObj).size());
         } else
           System.out.println("null");

       } catch (Exception e) {
         e.printStackTrace();
     }
   }
}





--- In xmlpull-user@yahoogroups.com, "Aleksander Slominski"
<aslom@...> wrote:
>
> XPath with namespaces definitely works - i used it many times :)
>
> make sure that XML parsed is with namespace aware builder mdoe set
on?
>
> and if it does nto help please post a full java file that can be
executed to
> reproduce the error including what exactly XXP3 jar file you used.
>
> thanks,
>
> Alek
>
>
> On 10/30/07, lipafrog <lipafrog@...> wrote:
> >
> > Hi all,
> >
> > I am using XPP3 to parse a document containing a custom namespace
> > and use an XPath predicate to pull out an element, but XPP3 does
not
> > find the element! Without the namespace this example works fine,
add
> > the namespace and it returns nothing. Have I failed to use XML
> > namespaces/XPP3 correctly? If so, could someone please point out
how?
> >
> > Thanks!
> > EG
> >
> > The XML is like:
> > <ns1:A xmlns:ns1="http://some.url.org">
> > <ns1:B>
> >    <ns1:C xyz="test"/>
> > </ns1:B>
> > </ns1:A>
> >
> > The code I try to use looks like, and returns an empty ArrayList:
> > Xb1XPath predicateObj = new Xb1XPath("/ns1:A/ns1:B");
> >
> > Object retObj = predicateObj.evaluate(docObj);
> >
> > if (retObj != null) {
> > System.out.println(retObj.getClass().getName());
> >
> > if (retObj instanceof ArrayList) {
> >    System.out.println(((ArrayList) retObj).size());
> > }
> > } else
> > System.out.println("null");
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
> --
> ---
> The best way to predict the future is to invent it - Alan Kay
>

#305 From: "Aleksander Slominski" <aslom@...>
Date: Tue Oct 30, 2007 6:25 pm
Subject: Re: XPP3 Namespace Use
as10m
Offline Offline
Send Email Send Email
 
XPath with namespaces definitely works - i used it many times :)
 
make sure that XML parsed is with namespace aware builder mdoe set on?
 
and if it does nto help please post a full java file that can be executed to reproduce the error including what exactly XXP3 jar file you used.
 
thanks,
 
Alek

 
On 10/30/07, lipafrog <lipafrog@...> wrote:
Hi all,

I am using XPP3 to parse a document containing a custom namespace
and use an XPath predicate to pull out an element, but XPP3 does not
find the element! Without the namespace this example works fine, add
the namespace and it returns nothing. Have I failed to use XML
namespaces/XPP3 correctly? If so, could someone please point out how?

Thanks!
EG

The XML is like:
<ns1:A xmlns:ns1="http://some.url.org">
<ns1:B>
   <ns1:C xyz="test"/>
</ns1:B>
</ns1:A>

The code I try to use looks like, and returns an empty ArrayList:
Xb1XPath predicateObj = new Xb1XPath("/ns1:A/ns1:B");

Object retObj = predicateObj.evaluate(docObj);

if (retObj != null) {
System.out.println(retObj.getClass().getName());

if (retObj instanceof ArrayList) {
   System.out.println(((ArrayList) retObj).size());
}
} else
System.out.println("null");




Yahoo! Groups Links

<*> To visit your group on the web, go to:
   http://groups.yahoo.com/group/xmlpull-user/

<*> Your email settings:
   Individual Email | Traditional

<*> To change settings online go to:
   http://groups.yahoo.com/group/xmlpull-user/join
   (Yahoo! ID required)

<*> To change settings via email:
   mailto:xmlpull-user-digest@yahoogroups.com
   mailto: xmlpull-user-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
   xmlpull-user-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
   http://docs.yahoo.com/info/terms/




--
---
The best way to predict the future is to invent it - Alan Kay

#304 From: "lipafrog" <lipafrog@...>
Date: Tue Oct 30, 2007 5:13 pm
Subject: XPP3 Namespace Use
lipafrog
Offline Offline
Send Email Send Email
 
Hi all,

I am using XPP3 to parse a document containing a custom namespace
and use an XPath predicate to pull out an element, but XPP3 does not
find the element! Without the namespace this example works fine, add
the namespace and it returns nothing. Have I failed to use XML
namespaces/XPP3 correctly? If so, could someone please point out how?

Thanks!
EG

The XML is like:
<ns1:A xmlns:ns1="http://some.url.org">
   <ns1:B>
     <ns1:C xyz="test"/>
   </ns1:B>
</ns1:A>

The code I try to use looks like, and returns an empty ArrayList:
Xb1XPath predicateObj = new Xb1XPath("/ns1:A/ns1:B");

Object retObj = predicateObj.evaluate(docObj);

if (retObj != null) {
   System.out.println(retObj.getClass().getName());

   if (retObj instanceof ArrayList) {
     System.out.println(((ArrayList) retObj).size());
   }
} else
   System.out.println("null");

#303 From: "javame.developer" <javame.developer@...>
Date: Mon Sep 10, 2007 3:44 pm
Subject: Optimizations - pruning
javame.devel...
Offline Offline
Send Email Send Email
 
Hello, programmers.

[I know that this is not exactly a xmlpull question but, if I am not
mistaken, kXml2 does use xmlpull.]

I read an article about optimizations and the article stated that one
should NOT put source into a package well that was easy enough to do.
However, it also went on to suggest that one should remove third
party libraries from their packages rather than just dump it into the
project. How do I do this? I am using "kXml2" parser and I can't see
how to unjar it and remove it from it's package unless I get the
source code and do it manually.

The reasoning behind this is that java generates a lot of overhead
when handling classes that are part of a package.

Any suggests on how to remove 3rd party libraries from their packages?

Thanks,
-------
JavaME (J2ME), Java, C & C# Developer
CV: http://docs.google.com/Doc?id=dt6fqcn_51dn8gds

#302 From: Aleksander Slominski <aslom@...>
Date: Thu Aug 16, 2007 12:18 am
Subject: Re: XmlPullParserException: could not resolve entity named
as10m
Offline Offline
Send Email Send Email
 
prasad wrote:
> I tried to run the sample program of xpp3 MyXmlPullApp.java with
> parametr of a sample xml file containing external entities defined in
> dtd is failed to execute with the following error message
>
> Exception in thread "main" org.xmlpull.v1.XmlPullParserException: could
> not resolve entity named 'para' (position: START_TAG
> seen ...<italic>References are to paragraph (&para;... @7:114)
>  at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1282)
>  at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
>  at com.xpp.XmlPullAppFile.processDocument
> (XmlPullAppFile.java:89)
>  at com.xpp.XmlPullAppFile.main(XmlPullAppFile.java:51)
>
> Can any one help, how to resolve the entity references
>
XPP3 does not support DTDs - as workaround for entities you can define
your own replacement.

best,

Alek
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#301 From: Aleksander Slominski <aslom@...>
Date: Thu Aug 16, 2007 12:18 am
Subject: Re: Can XMLPULL API transform document using XSLT file
as10m
Offline Offline
Send Email Send Email
 
prasad wrote:
> Can XMLPULL API transform xml document using XSLT file.
>
no

best,

Alek

#300 From: "prasad" <varma_mumbai@...>
Date: Tue Aug 14, 2007 9:43 pm
Subject: Can XMLPULL API transform document using XSLT file
varma_mumbai
Offline Offline
Send Email Send Email
 
Can XMLPULL API transform xml document using XSLT file.

#299 From: "prasad" <varma_mumbai@...>
Date: Tue Aug 14, 2007 9:41 pm
Subject: XmlPullParserException: could not resolve entity named
varma_mumbai
Offline Offline
Send Email Send Email
 
I tried to run the sample program of xpp3 MyXmlPullApp.java with
parametr of a sample xml file containing external entities defined in
dtd is failed to execute with the following error message

Exception in thread "main" org.xmlpull.v1.XmlPullParserException: could
not resolve entity named 'para' (position: START_TAG
seen ...<italic>References are to paragraph (&para;... @7:114)
	 at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1282)
	 at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093)
	 at com.xpp.XmlPullAppFile.processDocument
(XmlPullAppFile.java:89)
	 at com.xpp.XmlPullAppFile.main(XmlPullAppFile.java:51)

Can any one help, how to resolve the entity references

#298 From: Aleksander Slominski <aslom@...>
Date: Thu Jul 5, 2007 1:28 pm
Subject: Re: problems - unable to remove prefixes from generatedXML
as10m
Offline Offline
Send Email Send Email
 
diehardwomble wrote:
> Hi,
> I am using the kXML API in particular the XmlSerializer however all
> my xml tags are generated with a prefix on them for example:
>
> If i was trying to generate:
>
> <test id='123'></test>
>
> it is coming out as:
>
> <n0:test n0:id='123'><n0:test>
>
> i have tried using
>
> setPrefix("",NAMESPACE)
>
> however this at best only manages to do:
>
> <test n0:id='123'></n0:test>
>

> am I doing something wrong? is more information required?
>
looks like a bug in kXML - do use the latest version? did you try to run
the same code with XPP3 to verify?

best,

Alek
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#297 From: "diehardwomble" <MIjohnson21@...>
Date: Tue Jul 3, 2007 3:55 pm
Subject: problems - unable to remove prefixes from generatedXML
diehardwomble
Offline Offline
Send Email Send Email
 
Hi,
I am using the kXML API in particular the XmlSerializer however all
my xml tags are generated with a prefix on them for example:

If i was trying to generate:

<test id='123'></test>

it is coming out as:

<n0:test n0:id='123'><n0:test>

i have tried using

setPrefix("",NAMESPACE)

however this at best only manages to do:

<test n0:id='123'></n0:test>

am I doing something wrong? is more information required?

#296 From: Aleksander Slominski <aslom@...>
Date: Wed Jun 6, 2007 7:14 pm
Subject: Re: java.io.EOFException: no more data available
as10m
Offline Offline
Send Email Send Email
 
Aleksander Slominski wrote:
> Martin Woolley wrote:
>
>> Hi
>>
>> I'm stress testing an application that uses XPP3. I'm seeing the
>> following stacktrace sporadically:
>>
>> java.io.EOFException: no more data available
>> Thread-5:       at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2659)
>> Thread-5:       at org.xmlpull.mxp1.MXParser.more(MXParser.java:2666)
>> Thread-5:       at
>> org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1385)
>> Thread-5:       at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1370)
>> Thread-5:       at org.xmlpull.mxp1.MXParser.next(MXParser.java:1111)
>> Thread-5:       at
>>
com.nmss.ms.agent.api.XppStreamHandler.processDocument(XppStreamHandler.java:67)
>> Thread-5:       at com.nmss.ms.agent.api.ApiWorker.run(ApiWorker.java:193)
>> Thread-5:       at java.lang.Thread.run(Thread.java:534)
>>
>>
>> I have checked the XML input document and it looks fine.
>>
>> My instincts tell me I've hit some kind of synchronisation issue....
>> but I could be wildly wrong.
>>
>>
> are you using the same parser instance in multiple threads? this is not
> supported. as noted in docs and as it is usual for XML parser: XPP3 is
> not multi thread safe and each thread should have its own instance of
> parser. you can use parser pool (see xmlpull.org addons) if you want to
> recycle parser instances (run some perf test with and without pooling ot
> make sure you get optimal perf)
>
one more addition maybe it is obvious but ... you can use the same
instance in multiple threads *if* you will do all synchronization to
make sure no two threads are accessing parser (and its input) in the
same time.

best,

Alek
>> Are there are known issues that produce this Exception?
>>
>> Thank in anticipation
>>
>> Martin
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#295 From: Aleksander Slominski <aslom@...>
Date: Wed Jun 6, 2007 7:13 pm
Subject: Re: java.io.EOFException: no more data available
as10m
Offline Offline
Send Email Send Email
 
Martin Woolley wrote:
> Hi
>
> I'm stress testing an application that uses XPP3. I'm seeing the
> following stacktrace sporadically:
>
> java.io.EOFException: no more data available
> Thread-5:       at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2659)
> Thread-5:       at org.xmlpull.mxp1.MXParser.more(MXParser.java:2666)
> Thread-5:       at
> org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1385)
> Thread-5:       at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1370)
> Thread-5:       at org.xmlpull.mxp1.MXParser.next(MXParser.java:1111)
> Thread-5:       at
>
com.nmss.ms.agent.api.XppStreamHandler.processDocument(XppStreamHandler.java:67)
> Thread-5:       at com.nmss.ms.agent.api.ApiWorker.run(ApiWorker.java:193)
> Thread-5:       at java.lang.Thread.run(Thread.java:534)
>
>
> I have checked the XML input document and it looks fine.
>
> My instincts tell me I've hit some kind of synchronisation issue....
> but I could be wildly wrong.
>
are you using the same parser instance in multiple threads? this is not
supported. as noted in docs and as it is usual for XML parser: XPP3 is
not multi thread safe and each thread should have its own instance of
parser. you can use parser pool (see xmlpull.org addons) if you want to
recycle parser instances (run some perf test with and without pooling ot
make sure you get optimal perf)

HTH,

Alek
> Are there are known issues that produce this Exception?
>
> Thank in anticipation
>
> Martin
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#294 From: "Martin Woolley" <martin@...>
Date: Wed Jun 6, 2007 12:32 pm
Subject: java.io.EOFException: no more data available
martin_woolley
Offline Offline
Send Email Send Email
 
Hi

I'm stress testing an application that uses XPP3. I'm seeing the
following stacktrace sporadically:

java.io.EOFException: no more data available
Thread-5:       at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:2659)
Thread-5:       at org.xmlpull.mxp1.MXParser.more(MXParser.java:2666)
Thread-5:       at
org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1385)
Thread-5:       at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1370)
Thread-5:       at org.xmlpull.mxp1.MXParser.next(MXParser.java:1111)
Thread-5:       at
com.nmss.ms.agent.api.XppStreamHandler.processDocument(XppStreamHandler.java:67)
Thread-5:       at com.nmss.ms.agent.api.ApiWorker.run(ApiWorker.java:193)
Thread-5:       at java.lang.Thread.run(Thread.java:534)


I have checked the XML input document and it looks fine.

My instincts tell me I've hit some kind of synchronisation issue....
but I could be wildly wrong.

Are there are known issues that produce this Exception?

Thank in anticipation

Martin

#293 From: Phil Troy <PhilTroy@...>
Date: Sun Apr 15, 2007 2:50 am
Subject: Re: XMLPullParser set up in Eclipse
philtroy2001
Offline Offline
Send Email Send Email
 
Dear Aleksander

Thanks for your help; I am very pleased with the ease of using XMLPullParser.

Keep up the good work!

Phil


>Phil Troy wrote:
> > Dear Aleksander
> >
> > Hi!
> >
> > I bypassed the problem of the missing XmlPullParserFactory class by
> > creating the relevant packages and creating classes within them as
> > needed so that I now have the following projects/classes:
> >
> > - org.xmlpull.v1
> > - XmlPullParser.java
> > - XmlPullParserException
> > - XmlPullParserFactory
> > - XmlSerializer
> >
> > - org.xmlpull.mxp1
> > - MxParser.java
> >
> > But now, when I run the following statement it throws an exception on
> > the following line of code
> >
> > XmlPullParserFactory factory =
> >
>
XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERT\
Y_NAME),
>
> > null);
> >
> > I presume that it is because I am not properly setting the class to
> > MxParser.java - if that is the problem, can you please tell me how to
> > do that? I did look at the
> >
> > Class XmlPullParserFactory documentation, and did see the reference to
> >
> > Thread.getContextClassLoader().getClass() but I don't know how to get
> > that to work.
> >
>calling System.getProperty(XmlPullParserFactory.PROPERTY_NAME) allwos
>you to override parser impl class with system property. in case if it is
>null then factory loads parse class impl name from special file in
>META-INF directory and if you donot have this file it fails
>
>you can by pass it by simply calling:
>
>XmlPullParserFactory.newInstance("org.xmlpull.mxp1.MXParser",null)
>
>or simply
>
>XmlPullParser pp = new org.xmlpull.mxp1.MXParser()
>
>anyway you should not need to do anything like this if you used
>xpp3-1.1.4c.jar - in such case factory should just work so i suspect
>there must be something eerie in your CLASSPATH project. it may be wort
>to create new workspace and bran new project in eclipse and see how
>things work in such case.
>
>best,
>
>alek
>
>

Philip M. Troy, Ph.D.,
Decision Support Systems Analyst
PhilTroy@...
www.PhilTroy.com

#292 From: Aleksander Slominski <aslom@...>
Date: Mon Apr 2, 2007 6:10 pm
Subject: Re: XmlPullParserException: entity reference name can not contain character =
as10m
Offline Offline
Send Email Send Email
 
pledreau wrote:
> Hello, in my xsl file I have
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output method="xml" version="1.0"/>
> ...
> <xmlpost>
>         <xsl:value-of select="$donnee" disable-output-
> escaping="yes"/>
> </xmlpost>
> ...
>
> in my java code :
> ...
> transformer.transform(new DOMSource((Document)arbre), new
> StreamResult(stream));
> ...
>
> When I run this program I obtain :
> org.xmlpull.v1.XmlPullParserException: entity reference name can not
> contain character =' (position: TEXT seen ...<xmlpost>Ap
> pl=WEBACC&Ident=... @21:28)
>
> That happens on the following string :
> /cgi-bin/emxml?Appl=WEBACC&Ident=00000000&Secret=00
>
> I'm using disable-output-escaping="yes" to obtain in my output stream
> <xmlpost>/cgi-bin/emxml?
> Appl=WEBACC&Ident=00000000&Secret=00</xmlpost>
>
> instead of
>
> <xmlpost>/cgi-bin/emxml?
> Appl=WEBACC&Amp;Ident=00000000&Amp;Secret=00</xmlpost>
>
> The running jre is 1.2
>
> How can I solve this problem ?
>
"&Ident" is interpeted as name of entity - this is not allowed in XML
and must be escaped use &amp; (not &Amp;) and all should work fine.

best,

alek
> thanks in advance
>
> PLedreau
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#291 From: "pledreau" <pledreau@...>
Date: Mon Apr 2, 2007 4:21 pm
Subject: XmlPullParserException: entity reference name can not contain character =
pledreau
Offline Offline
Send Email Send Email
 
Hello, in my xsl file I have
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0"/>
...
<xmlpost>
         <xsl:value-of select="$donnee" disable-output-
escaping="yes"/>
</xmlpost>
...

in my java code :
...
transformer.transform(new DOMSource((Document)arbre), new
StreamResult(stream));
...

When I run this program I obtain :
org.xmlpull.v1.XmlPullParserException: entity reference name can not
contain character =' (position: TEXT seen ...<xmlpost>Ap
pl=WEBACC&Ident=... @21:28)

That happens on the following string :
/cgi-bin/emxml?Appl=WEBACC&Ident=00000000&Secret=00

I'm using disable-output-escaping="yes" to obtain in my output stream
<xmlpost>/cgi-bin/emxml?
Appl=WEBACC&Ident=00000000&Secret=00</xmlpost>

instead of

<xmlpost>/cgi-bin/emxml?
Appl=WEBACC&Amp;Ident=00000000&Amp;Secret=00</xmlpost>

The running jre is 1.2

How can I solve this problem ?

thanks in advance

PLedreau

#290 From: Aleksander Slominski <aslom@...>
Date: Mon Apr 2, 2007 4:27 am
Subject: Re: XMLPullParser set up in Eclipse
as10m
Offline Offline
Send Email Send Email
 
Phil Troy wrote:
> Dear Aleksander
>
> Hi!
>
> I bypassed the problem of the missing XmlPullParserFactory class by
> creating the relevant packages and creating classes within them as
> needed so that I now have the following projects/classes:
>
> - org.xmlpull.v1
>    - XmlPullParser.java
>    - XmlPullParserException
>    - XmlPullParserFactory
>    - XmlSerializer
>
> - org.xmlpull.mxp1
>    - MxParser.java
>
> But now, when I run the following statement it throws an exception on
> the following line of code
>
> XmlPullParserFactory factory =
>
XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERT\
Y_NAME),
> null);
>
> I presume that it is because I am not properly setting the class to
> MxParser.java - if that is the problem, can you please tell me how to
> do that?  I did look at the
>
> Class XmlPullParserFactory documentation, and did see the reference to
>
> Thread.getContextClassLoader().getClass() but I don't know how to get
> that to work.
>
calling System.getProperty(XmlPullParserFactory.PROPERTY_NAME)  allwos
you to override parser impl class with system property. in case if it is
null then factory loads parse class impl name from special file in
META-INF directory and if you donot have this file it fails

you can by pass it by simply calling:

XmlPullParserFactory.newInstance("org.xmlpull.mxp1.MXParser",null)


or simply

XmlPullParser pp = new org.xmlpull.mxp1.MXParser()

anyway you should not need to do anything like this if you used
xpp3-1.1.4c.jar - in such case factory should just work so i suspect
there must be something eerie in your CLASSPATH project. it may be wort
to create new workspace and bran new project in eclipse and see how
things work in such case.

best,

alek

#289 From: Phil Troy <PhilTroy@...>
Date: Mon Apr 2, 2007 3:57 am
Subject: Re: XMLPullParser set up in Eclipse
philtroy2001
Offline Offline
Send Email Send Email
 
Dear Aleksander

Hi!

I bypassed the problem of the missing XmlPullParserFactory class by
creating the relevant packages and creating classes within them as
needed so that I now have the following projects/classes:

- org.xmlpull.v1
    - XmlPullParser.java
    - XmlPullParserException
    - XmlPullParserFactory
    - XmlSerializer

- org.xmlpull.mxp1
    - MxParser.java

But now, when I run the following statement it throws an exception on
the following line of code

XmlPullParserFactory factory =
XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERT\
Y_NAME),
null);

I presume that it is because I am not properly setting the class to
MxParser.java - if that is the problem, can you please tell me how to
do that?  I did look at the

Class XmlPullParserFactory documentation, and did see the reference to

Thread.getContextClassLoader().getClass() but I don't know how to get
that to work.

Thanks/Phil

At 20:36 2007-04-01, you wrote:

>Aleksander Slominski wrote:
> > Phil Troy wrote:
> >
> >> Hi!
> >>
> >> I am using Eclipse, and have added xpp3_min-1.1.4c.jar to be an
> >> external jar for my current Eclipse project. I have added imports for
> >> xmlPullParser as follows:
> >>
> >> import org.xmlpull.v1.XmlPullParser;
> >> import org.xmlpull.v1.XmlPullParserException;
> >> import org.xmlpull.v1.XmlPullParserFactory;
> >>
> >> I build my project in Eclipse and get the following error "the
> >> import org.xmlpull.v1.XmlPullParserFactory cannot be resolved.
> >>
> >> (I am guessing that XmlPullParserFactory is not in the jar mentioned
> >> above.)
> >>
> >> How do I fix this problem?
> >>
> >>
> > min version (xpp3_min-1.1.4c.jar) is minimal and it does not have parser
> > factory - you have two options:
> > 1. create parser directly using its public constructor (new MXParser()
> > should work)
> >
> > 2. download standard xpp3 jar version
> >
>
<http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar>h\
ttp://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar
> > and then you can use XmlPullParserFactory
> >
>correction - i just checked [1] and you should be fine with min version
>(you need standard for serializer and faster parser) and [1] has
>XmlPullParserFactory so maybe you need to double check your jar file you
>use in Eclipse (and download it again if necessary) - also check if your
>eclipse project classpath settings do nto have duplicate of xpp3/xmlpull
>interfaces/classes
>
>HTH,
>
>alek
>[1]
><http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3_min-1.1.4c.\
jar>http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3_min-1.1.4\
c.jar
>
>

Philip M. Troy, Ph.D.,
Decision Support Systems Analyst
PhilTroy@...
www.PhilTroy.com

#288 From: Phil Troy <PhilTroy@...>
Date: Mon Apr 2, 2007 1:00 am
Subject: Re: XMLPullParser set up in Eclipse
philtroy2001
Offline Offline
Send Email Send Email
 
THANKS/Phil

At 20:29 2007-04-01, you wrote:

>Phil Troy wrote:
> > Hi!
> >
> > I am using Eclipse, and have added xpp3_min-1.1.4c.jar to be an
> > external jar for my current Eclipse project. I have added imports for
> > xmlPullParser as follows:
> >
> > import org.xmlpull.v1.XmlPullParser;
> > import org.xmlpull.v1.XmlPullParserException;
> > import org.xmlpull.v1.XmlPullParserFactory;
> >
> > I build my project in Eclipse and get the following error "the
> > import org.xmlpull.v1.XmlPullParserFactory cannot be resolved.
> >
> > (I am guessing that XmlPullParserFactory is not in the jar mentioned
> > above.)
> >
> > How do I fix this problem?
> >
>min version (xpp3_min-1.1.4c.jar) is minimal and it does not have parser
>factory - you have two options:
>1. create parser directly using its public constructor (new MXParser()
>should work)
>2. download standard xpp3 jar version
><http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar>\
http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar
>and then you can use XmlPullParserFactory
>
>HTH,
>
>alek
> > Philip M. Troy, Ph.D.,
> > Decision Support Systems Analyst
> > <mailto:PhilTroy%40Mail.com>PhilTroy@...
> > www.PhilTroy.com
> >
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>--
>The best way to predict the future is to invent it - Alan Kay
>
>

Philip M. Troy, Ph.D.,
Decision Support Systems Analyst
PhilTroy@...
www.PhilTroy.com

#287 From: Aleksander Slominski <aslom@...>
Date: Mon Apr 2, 2007 12:35 am
Subject: Re: XMLPullParser set up in Eclipse
as10m
Offline Offline
Send Email Send Email
 
Aleksander Slominski wrote:
> Phil Troy wrote:
>
>> Hi!
>>
>> I am using Eclipse, and have added xpp3_min-1.1.4c.jar to be an
>> external jar for my current Eclipse project.  I have added imports for
>> xmlPullParser as follows:
>>
>>   import org.xmlpull.v1.XmlPullParser;
>>   import org.xmlpull.v1.XmlPullParserException;
>>   import org.xmlpull.v1.XmlPullParserFactory;
>>
>> I build my project in Eclipse and get the following error "the
>> import org.xmlpull.v1.XmlPullParserFactory cannot be resolved.
>>
>> (I am guessing that XmlPullParserFactory is not in the jar mentioned
>> above.)
>>
>> How do I fix this problem?
>>
>>
> min version (xpp3_min-1.1.4c.jar) is minimal and it does not have parser
> factory - you have two options:
> 1. create parser directly using its public constructor (new MXParser()
> should work)
>
> 2. download standard xpp3 jar version
> http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar
> and then you can use XmlPullParserFactory
>
correction - i just checked [1] and you should be fine with min version
(you need standard for serializer and faster parser) and [1] has
XmlPullParserFactory so maybe you need to double check your jar file you
use in Eclipse (and download it again if necessary) - also check if your
eclipse project classpath settings do nto have duplicate of xpp3/xmlpull
interfaces/classes

HTH,

alek
[1]
http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3_min-1.1.4c.ja\
r

#286 From: Aleksander Slominski <aslom@...>
Date: Mon Apr 2, 2007 12:29 am
Subject: Re: XMLPullParser set up in Eclipse
as10m
Offline Offline
Send Email Send Email
 
Phil Troy wrote:
> Hi!
>
> I am using Eclipse, and have added xpp3_min-1.1.4c.jar to be an
> external jar for my current Eclipse project.  I have added imports for
> xmlPullParser as follows:
>
>   import org.xmlpull.v1.XmlPullParser;
>   import org.xmlpull.v1.XmlPullParserException;
>   import org.xmlpull.v1.XmlPullParserFactory;
>
> I build my project in Eclipse and get the following error "the
> import org.xmlpull.v1.XmlPullParserFactory cannot be resolved.
>
> (I am guessing that XmlPullParserFactory is not in the jar mentioned
> above.)
>
> How do I fix this problem?
>
min version (xpp3_min-1.1.4c.jar) is minimal and it does not have parser
factory - you have two options:
1. create parser directly using its public constructor (new MXParser()
should work)
2. download standard xpp3 jar version
http://www.extreme.indiana.edu/dist/java-repository/xpp3/jars/xpp3-1.1.4c.jar
and then you can use XmlPullParserFactory

HTH,

alek
> Philip M. Troy, Ph.D.,
> Decision Support Systems Analyst
> PhilTroy@...
> www.PhilTroy.com
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#285 From: "Phil Troy" <PhilTroy@...>
Date: Sun Apr 1, 2007 8:29 pm
Subject: XMLPullParser set up in Eclipse
philtroy2001
Offline Offline
Send Email Send Email
 
Hi!

I am using Eclipse, and have added xpp3_min-1.1.4c.jar to be an
external jar for my current Eclipse project.  I have added imports for
xmlPullParser as follows:

   import org.xmlpull.v1.XmlPullParser;
   import org.xmlpull.v1.XmlPullParserException;
   import org.xmlpull.v1.XmlPullParserFactory;

I build my project in Eclipse and get the following error "the
import org.xmlpull.v1.XmlPullParserFactory cannot be resolved.

(I am guessing that XmlPullParserFactory is not in the jar mentioned
above.)

How do I fix this problem?

Thanks/Phil

Philip M. Troy, Ph.D.,
Decision Support Systems Analyst
PhilTroy@...
www.PhilTroy.com

#284 From: Aleksander Slominski <aslom@...>
Date: Wed Nov 29, 2006 6:21 pm
Subject: RFC: XmlPull API 1.2
as10m
Offline Offline
Send Email Send Email
 
hi,

it is some time we did any modification to XmlPull API 1.1 (it is
remarkably stable) but there are few minor issues and improvements
recorded over years (and J2ME devices get bigger memory nowadays ...) so
it looks like good time for incremental release i.e. 1.2

based on list of issues and improvements (RFE) in bugzilla two stands out:

1) http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=167
skipSubTree() looks like a very useful method to have implemented in
parser (skipping can be fast) - that would add to XmlPullParser method:
    /**
      * Skip sub tree on which the parser is currently positioned on.
      * <br>NOTE: parser must be on START_TAG and when function returns
      * parser will be positioned on matching END_TAG
      *
      * This method is typically optimized by parser but the its logic
should follow this:
      * <code>
      * require(XmlPullParser.START_TAG, null, null);
      * int level = 1;
      * while(level > 0) {
      *   int eventType = next();
      *   if(eventType == XmlPullParser.END_TAG) {
      *     --level;
      *   } else if(eventType == XmlPullParser.START_TAG) {
      *     ++level;
      *   }
      * }
      * </code>
      */
     public void skipSubTree() throws XmlPullParserException, IOException;



2) http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=240
this is long standing issue related to how setPrefix() works and how it
should be working more like xmlns:pref='...' (so digital signatures code
works well) - that would add to XmlSerializer three new methods with
prefix as an argument:

public XmlSerializer startTag (String prefix, String namespace, String
name)
public XmlSerializer endTag (String prefix, String namespace, String name)
public XmlSerializer attribute (String prefix, String namespace, String
name, String value)

if there are any other issues/improvements/etc please let us know (send
email to xmlpull-dev and log the issues in bugzilla)

both XPP3/5 and kXML2 plan to implement soon XmlPull API 1.2

thanks,

Alek Slominski (& Stefan Haustein)

#283 From: "altconsultingcom" <altconsultingcom@...>
Date: Mon Nov 13, 2006 9:29 am
Subject: [ANN] XPP Demos: XML Visualization, Analytics, and High Performance Processing
altconsultin...
Offline Offline
Send Email Send Email
 
I am pleased to announce that I will be presenting at the Washington DC XML User Group this Wednesday 11-15-06.

For directions and more information on this user group:  http://www.eccnet.com/xmlug/ 



Here are the topics that I will discuss:


XML Visualization, Analytics, and High Performance Processing
  1. Major Themes
    • Visualization fosters comprehension
    • Analytics fosters insight
    • High performance processing requires performant architectures and new XML APIs
  2. History of HTML and XML Visualization
  3. Visualization and Comprehension
  4. XML Visualization Demos
  5. History of HTML and XML Analytics
  6. Analytics and Insight
  7. XML Analytics Demos
  8. Understanding High Performance XML Processing
  9. Using Visualization and Analytics technologies to help define new XML architectures and APIs
  10. New Architectures for XML Document Loading
  11. New XML Access/Search APIs: Introducing the "Exclude Others-style" API
  12. New Architecture for XML Document Serialization
  13. The requirement for XML transactions in applications: Implementing Spheres of Control
  14. Group Application #1: Using Visualization and Analytics to help build a Web 2.0 Mashup
  15. Group Application #2: Using the Exclude-Others API to efficiently


Of particular importance to the XPP community will be the discussion and demos of new XML processing architectures and APIs, many of which enhance the core XPP technology.


--Zaid

http://altmobile.com




#282 From: Aleksander Slominski <aslom@...>
Date: Mon Oct 23, 2006 5:13 am
Subject: Re: DOM2XmlPullBuilder
as10m
Offline Offline
Send Email Send Email
 
hi Fred,

an excellent bug report - now in bugzilla
http://www.extreme.indiana.edu/bugzilla/show_bug.cgi?id=246

and it is now fixed in xpp3-1.1.4 and in CVS - it is just one-liner (see
below)

thanks,

alek

  Revision  Changes    Path
   1.9       +29 -26   
xmlpull-api-v1/addons/java/dom2_builder/src/org/xmlpull/v1/dom2_builder/DOM2XmlP\
ullBuilder.java

   Index: DOM2XmlPullBuilder.java
   ===================================================================
   RCS file:
/l/extreme/cvspub/xmlpull-api-v1/addons/java/dom2_builder/src/org/xmlpull/v1/dom\
2_builder/DOM2XmlPullBuilder.java,v
   retrieving revision 1.8
   retrieving revision 1.9
   diff -u -b -t -w -r1.8 -r1.9
   --- DOM2XmlPullBuilder.java 23 Oct 2006 04:01:08 -0000 1.8
   +++ DOM2XmlPullBuilder.java 23 Oct 2006 05:05:58 -0000 1.9
   @@ -182,7 +182,10 @@
                        String prefix = pp.getNamespacePrefix(i);
                        for (int j = top; j > i; --j)
                        {
   -                        if(prefix.equals(pp.getNamespacePrefix(j))) {
   +                        String prefixJ = pp.getNamespacePrefix(j);
   +                        if((prefix != null && prefix.equals(prefixJ))
   +                               || (prefix != null && prefix == prefixJ) )
   +                        {
                                // prefix is already declared -- skip it
                                continue LOOP;
                            }






Frederick Burkley wrote:
> I'm looking into the DOM2XmlPullBuilder class and I get a
> NullPointerException when attempting to parse the following file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <ServerConfiguration xmlns=" http://your-namespace-here
> <http://your-namespace-here/>"
> xmlns:xsi="http://www.w3.org/2001/XMLSchem a-instance
> <http://www.w3.org/2001/XMLSchema-instance>" xsi:schemaLocation="
> http://your-namespace-here <http://your-namespace-here/> test.xsd">
>   <Server>savage-m60</Server>
> </ServerConfiguration>
>
>
> Although I can successfully parse the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <jtc:ServerConfiguration xmlns:jtc="http://your-namespace-here
> <http://your-namespace-here/>"
> xmlns:xsi="http://www.w3.org/2001/XMLSchem a-instance
> <http://www.w3.org/2001/XMLSchema-instance>"
> xsi:schemaLocation="http://your-namespace-here
> <http://your-namespace-here/> test.xsd">
>   <jtc:Server>savage-m60</jtc
> :Server>
> </jtc:ServerConfiguration>
>
>
>
> Is there something wrong with the first form of this instance document?
>
>
> Respectfully,
> Fred Burkley
>
>
> The sample parse code follows.
>
>
> import java.io.File;
> import java.io.FileReader ;
> import org.xmlpull.v1.dom2_builder.DOM2XmlPullBuilder;
>
> public class PullParserTest {
>   public static void main(String[] args) {
>     File file;
>     FileReader fileReader;
>     DOM2XmlPullBuilder pullBuilder;
>
>     if (args.length < 1) {
>       System.out.println("Enter the name of the XML file on the
> command line.");
>       System.exit(0);
>     }
>     try {
>       file = new File(args[0]);
>       fileReader = new FileReader(file);
>       pullBuilder = new DOM2XmlPullBuilder();
>       pullBuilder.parse(fileReader);
>     }
>     catch (Exception ex) {
>       ex.printStackTrace();
>     }
>   }
> }
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#281 From: Frederick Burkley <fburkley@...>
Date: Fri Oct 20, 2006 3:47 pm
Subject: DOM2XmlPullBuilder
fburkley
Offline Offline
Send Email Send Email
 
I'm looking into the DOM2XmlPullBuilder class and I get a NullPointerException when attempting to parse the following file:

<?xml version="1.0" encoding="UTF-8"?>
<ServerConfiguration xmlns=" http://your-namespace-here"  xmlns:xsi="http://www.w3.org/2001/XMLSchem a-instance" xsi:schemaLocation=" http://your-namespace-here test.xsd">
  <Server>savage-m60</Server>
</ServerConfiguration>


Although I can successfully parse the following:

<?xml version="1.0" encoding="UTF-8"?>
<jtc:ServerConfiguration xmlns:jtc="http://your-namespace-here" xmlns:xsi="http://www.w3.org/2001/XMLSchem a-instance " xsi:schemaLocation="http://your-namespace-here test.xsd">
  <jtc:Server>savage-m60</jtc
:Server>
</jtc:ServerConfiguration>



Is there something wrong with the first form of this instance document?


Respectfully,
Fred Burkley


The sample parse code follows.


import java.io.File;
import java.io.FileReader ;
import org.xmlpull.v1.dom2_builder.DOM2XmlPullBuilder;

public class PullParserTest {
  public static void main(String[] args) {
    File file;
    FileReader fileReader;
    DOM2XmlPullBuilder pullBuilder;

    if (args.length < 1) {
      System.out.println("Enter the name of the XML file on the command line.");
      System.exit(0);
    }
    try {
      file = new File(args[0]);
      fileReader = new FileReader(file);
      pullBuilder = new DOM2XmlPullBuilder();
      pullBuilder.parse(fileReader);
    }
    catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}



#280 From: Aleksander Slominski <aslom@...>
Date: Tue Oct 17, 2006 5:32 am
Subject: Re: XML Pull Parsers for a of compressed file containing a set of XML files
as10m
Offline Offline
Send Email Send Email
 
Nitin wrote:
> 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"...
that would indicate that there is something <?xml version="1.0"
encoding="ISO-8859-1"?> in your input after decompressin - if it is
tar.gz it is not enough to decompress you need also to extract each file
from tar archive.

to verify try to gzip an XML file and then parse - i bet it would work ;-)

best,

alek
> (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
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>


--
The best way to predict the future is to invent it - Alan Kay

#279 From: "Nitin" <ndnair1979@...>
Date: Tue Oct 17, 2006 4:17 am
Subject: XML Pull Parsers for a of compressed file containing a set of XML files
ndnair1979
Offline Offline
Send Email Send Email
 
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

Messages 279 - 308 of 308   Newest  |  < Newer  |  Older >  |  Oldest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help