Javax.xml.stream.XMLInputFactory problems with &

Hi all
I am using javax.xml.stream.XMLInputFactory to create an XMLStreamReader, which reads XML in from a database.
The problem is that when it encounters & entities, it is replacing them simply with &. When I then go to transform the XML with an XSL stylesheet, it fails with a parser error due to the presence of unescaped & characters.
Looking at the API documentation, I thought that setting the property javax.xml.stream.isReplacingEntityReferences to false would solve the problem, but it isn't. The line of code I am using is as follows: -
inputFactory.setProperty("javax.xml.stream.isReplacingEntityReferences", new Boolean(false));
Any further ideas as to what I am doing wrong or what else I should be doing?
Many thanks for reading and considering my post.
Kind Regards
Jon

Thanks for your continued posts guys...
Quote from DrClap: "So if you consider this to be a problem, you are most likely misunderstanding. Or is there a reason why you feel you have to know how the text was represented in the document it came from?"
Right, just to clarify, this is what I'm trying to do...
1. XML, complete with properly escaped characters (&, etc) is sitting in the database.
2. Next, I am attempting to read the XML into memory character for character via an XMLInputStream and so I still want &, etc, not just &.
3. Finally, I apply stylesheet to XML Now I do want the parser to decode the & into &. The problem is that it has already been done in 2 (above) so the parser in 3 falls over.
Thanks for pointing out that javax.xml.stream.XMLInputFactory is not a standard class DrClap - looks like it's back to the drawing board for me!!
Thanks
Jon

Similar Messages

  • Javax.xml.stream import problem???? plz help

    hi, i am looking into using stax to write to xml, however i believe i need some classes contained within javax.xml.stream.*; and this is not contained within j2se docs i know, i think it comes with the web services.
    what i wanted to know is as i am using netbeans what is the best way for me to use these packages as i still need the current ones contained within j2se for the rest of my app
    thanks
    Danny =)

    do i have to download another jre or can it be done using the one i currently have, j2se 1.9

  • Problem in javax.xml.stream package

    i am getting some trouble while using the import statement for following package:-
    import javax.xml.stream.*;
    I have j2sdk1.4.2 installed in my system. I am using NetBeans 3.6 IDE.
    Should i copy some jars in order to resolve this issue. You can send me the steps at:- [email protected]
    Please help me.
    Regards
    Sks

    Have not been able to find anything in the bug database.
    I am alittle worried that the StAX - 1.0.1 (http://stax.codehaus.org) has a method with the same signature that does something very different.

  • Javax.xml.stream.XMLStreamException throws when present '&' character

    Hi
    I am writing a code using stax parser. But recently I got an error when "&" or "&" present in the xml document.
    This is the error I am getting
    javax.xml.stream.XMLStreamException: ParseError at [row,col]:[30,30]
    Message: The reference to entity "name" must end with the ';' delimiter.This is my xml
    <url>  http://url?id=1&name=aaa  </url>  This is my code
    XMLInputFactory xmlInputFactory =  XMLInputFactory.newInstance();
                xmlInputFactory.setProperty(
                        XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES,
                        Boolean.TRUE);
                xmlInputFactory.setProperty(
                        XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES,
                        Boolean.FALSE);
                xmlInputFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
    String xmlSource;
    XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(xmlSource.getBytes("UTF-8")));
    while (reader.hasNext())
      reader.next(); // error throws in this line
    }Can someone please help me.

    Sorry for the late reply. I was waited with the intention because this was my fault.
    Yes I am using & amp;
    But the problem return persist.
    Now I have identified the problem.
    The problem was I am using same xml for process multiple time.
    First time it does not fail.
    But the second time I am assigning the processed xml to a string and use this string as a input to the second xml processing.
    This time it automatically replace all & amp; with & .
    Now it fails.
    To eliminate this What I have done is when reading text and attribute values I am do a simple string replacing process.
    protected String encode2XML(String source)
            String src = source;
            if (src != null)
                src = src.replace("&", "&");
                src = src.replace("<", "<");
                src = src.replace(">", ">");
                src = src.replace("\"", """);
                src = src.replace("\'", "&#039;");
                return src;
            else
                return "";
        }

  • JAXP 1.4 in JDK 1.5? javax.xml.stream.FactoryFinder$ConfigurationError

    hello,
    i'm forced to develop in jdk 1.5 and need to use package javax.xml.stream (StAX), which is not included in jaxp1.3 (in jdk 5), so there is a need to somehow integrate jaxp 1.4 to jdk5.
    first thing i've tried was getting jaxp 1.4 src and include a buildpath to my project to it. problem is, that javax.xml.stream.XMLOutputFactory.newInstance() throws exception javax.xml.stream.FactoryFinder$ConfigurationError: Provider com.sun.xml.internal.stream.XMLOutputFactoryImpl not found
    thanks in advance

    problem solved

  • Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream

    I am trying to develop a web service client for amazon webservice.but i am getting this error while running the app. Can anyone please help me. I have installed the JWSDP and but could not understand why i have to locate all the jar files in the classpath?Please help.
    ===== error=========================================
    C:\abr\classes>java -classpath c:\abr\test.jar;C:\abr\jaxrpc-api.jar;C:\abr\jaxrpc-impl.jar;C:\abr\jaxrpc-spi.jar;c:\abr\classes\amazon.jar;C:\abr\mail.jar;C:\a
    br\saaj-api.jar;C:\abr\activation.jar;c:\abr\FastInfoset.jar;%classpath% Client
    [b]Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/stream/XMLS
    treamWriter
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at com.sun.xml.rpc.client.StreamingSender._writeRequest(StreamingSender.
    java:672)
    at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:87)
    at amazon.AmazonSearchPort_Stub.authorSearchRequest(AmazonSearchPort_Stu
    b.java:988)
    at Client.main(Client.java:21)

    I'm assuming you're using JWSDP 1.6 as I see Fastinfoset.jar in your list. You are missing some jar files in your classpath there. The best way to know what you need is to look at the release notes for JWSDP 1.6. Since you're building a web serivce start with the table in there and lookup JAX-RPC. It'll show you what jar files are needed and what other libraries are needed. Now depending on what you're doing you don't really need all those.
    For sure you're missing jsr173_api.jar which is where I believe that class you need is located. This is in the JWSDP_1_6\sjsxp\lib directory. You will probably need the other jar thats in there too. Best bet is to follow the dependancy chart in the release notes.
    This should get you going.
    Ryan

  • Javax.xml.stream is not found

    I'm running eclipse on a mac using java 6.
    And for some reason eclipse cant find javax.xml.stream
    does anyone know where i can download this file?
    and or how I can tell eclipse where to find it?
    Thanks!

    alan_mehio wrote:
    Hi,
    You definitely will get more help if you post your question with eclipse related forumUnless someone points out that javax.xml.stream simply isn't part of J2SE. You can download it here

  • Streaming Video problems with Latest update of Lion.

    Having major issues with streaming youtube videos since the latest Lion update.  The videos play halfway through and then just stop, every video that I try.  Other news websites that used to play flawlessly are also hanging up. Is this a youtube issue or are others having problems with Lion in regards to videos.  iMac Intel

    None here.

  • Javax.naming.PartialResultException (ConnectionException) problem with MSAD

    Hi,
    I have BPM 10gR3 installation connected to Microsoft Active Directory (both on the same VMWare host) and get the following intermittent errors being reported.
    "Exception [javax.naming.PartialResultException [Root exception is javax.naming.CommunicationException: migrations.com.au:389
    \[Root exception is java.net.ConnectException: connect: Address is invalid on local machine, or port is not valid on remote machine\]]]"
    Has anyone run into this problem before or know of a fix?
    I've trolled through some other forums and have found other applications reporting similar problems. I think this has something to do with my AD or DNS settings.
    It's intermittent because I'm able to run my project from time to time but when it hits this condition the engine reports unexpected error has occurred (during an interaction with an instance) or when attempting to login. When things are working I'm able to access the User/participant information. I've created my AD users in an Org Unit called "al" and the users are not listed in the default Users container.
    TP

    Looks like it was a problem with DNS. Built the DNS (and used it) server first and then AD separately (pointing to this DNS) instead of allowing Win 2K3 Server to build AD and DNS the same time.
    TP

  • [XML/XPATH] jaxen : problem with "parent" function

    Hello
    I have a problem with jaxen, when I try to use the XPath function parent :
    When I try this :
    import ...
    DocumentNavigator dn=new DocumentNavigator();
    try {
    objet=dn.getDocument("TESTXPath.xml");
    apath=dn.parseXPath("/Entry/Resultats/step/Population/individu/*");
    result=apath.evaluate(objet);
    System.out.println(result);
    apath=dn.parseXPath("/Entry/Resultats/step/Population/parent::*");
    result=apath.evaluate(objet); // ---> exception
    System.out.println(result);
    catch(Exception e) {
    e.printStackTrace();
    The first result is well displayed, but just before the second, I catch this exception:
    Exception in thread "main" java.lang.NoSuchMethodError: org.jdom.Element.getParent()Lorg/jdom/Element; at org.jaxen.jdom.DocumentNavigator.getParentAxisIterator(DocumentNavigator.java: 252)
    at org.jaxen.expr.iter.IterableParentAxis.iterator(IterableParentAxis.java:82)
    at org.jaxen.expr.DefaultStep.axisIterator(DefaultStep.java:139)
    at org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:188)
    at org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocationPat h.java:126)
    at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:107)
    at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:716)
    at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:239)
    at org.jaxen.BaseXPath.evaluate(BaseXPath.java:196)
    at MainTestClass.main(MainTestClass.java:85)
    However, the first query works good and I received list so I'm quite sure that it's not a problem of unfindable elements.
    Finaly I can't be syccessful to use XPath parent function:
    Either I catch an exception, or it returns nothing or empty list
    Isn't the XPath syntax correct in my second expression ?
    Can we do :
    /.../.../parent::* ? ou //individu/parent::* ?

    Thanks
    I think so, but.
    In fact I don't think I'm using different version of JDOM.
    I use eclipse with jdk1.4.2.
    I have downloaded JDOM-b10 and the only things I have done is to extract zip archive and to add all .jar files of the jdom directory in my library path.
    Do this is the only version of JDOM I'm using.
    All works perfectly excepted only the XPath parent method. It's strange that the other methods work fine.
    I don't knnow how to solve this problem ! so if you can help me I be very thankfull.

  • FCP XML to Flint - Problems with Time Remap

    My Flint artist and I have had some problems with the XML Export and Import that we cannot figure out. The XMLs from FCP sequences that have variable speed Time Remaps applied show up on the Flint with those particular clips with the wrong in/out points in both the source and record times. Also, the speed ramp info doesn't show up properly.
    We have followed the Flint manual to a T on importing correctly. Anyone encountered this or know a solution? Especially why it's throwing off the in points. It screws the whole timeline when that happens.
    Thanks in advance.

    The TimerEvent target is a flash.utils.Timer object and does
    not contain a reference to your lblTimeUntil label.
    Recode
    trace("Seconds Left" + evt.target.lblTimeUntil.text);
    to
    trace("Seconds Left" + lblTimeUntil.text);
    and you will not blow up anymore.
    This code will display the count up till refresh.
    public function onTick(evt:TimerEvent):void {
    var minuteTimer:Timer = evt.target as Timer;
    lblTimeUntil.text = minuteTimer.currentCount.toString();

  • HT4623 Streaming audio problems with io6

    Everytime I try to access a streaming aidio site, it will start playing and stop after bout a minute? I never use to have any problems with it on my previous version of software...is anyone else having the same problem?!

    I am accessing the site via wi-fi connection...have a BB Bold as well and works fine...

  • File Stream Open Problem with g++ 3.3.3 and libstdc++.so.5

    Hi
    I am facing one problem when I complie and run my code
    with the following compiler and standard C++ library :
    OS Used : SunOS GUILIN 5.8 Generic_108528-13 sun4u sparc SUNW,UltraAX-i2
    Compiler Used : g++ 3.3.3
    Standard Library Used : libstdc++.so.5
    Problem : I am supposed to create 1000 file streams,
    but when I run my program, it creates only 254 file streams,
    after that assertion occurs!!!!
    OUTPUT :
    ========
    $ echo $SHELL
    /usr/bin/sh
    $
    $ ulimit -n
    50000
    $
    $ ./a.out
    i : 253
    errno : 24
    Assertion failed: in, file main.cpp, line 28
    Abort - core dumped
    $
    ========
    MY CODE :
    ==================================================
    #include <sys/errno.h>
    #include <assert.h>
    #include <fstream>
    #include <iostream>
    #include <string>
    extern int errno;
    const int MAX_STREAM = 1000;
    using namespace std;
    int main(int argc, char* argv[])
    ifstream in[MAX_STREAM];
    string file("boo");
    for ( int i=0; i != MAX_STREAM; i++ )
    in[i].open(file.c_str());
    if ( errno > 0 ) {
    cout << "i : " << i << endl;
    cout << "errno : " << errno << endl;
    } // end of "if ( errno > 0 ) {"
    assert(in[i]);
    return 0;
    ===================================================
    But, if I compile the exactly same program with the
    following compiler and run the executable under the
    same environment as above, it is running without
    any problem and 1000 file streams are created
    smoothly without any assertion.
    OS Used : SunOS GUILIN 5.8 Generic_108528-13 sun4u sparc SUNW,UltraAX-i2
    Compiler Used : g++ 2.95.3
    Standard Library Used : libstdc++.so.2.10.0
    Anybody can help me to overcome this problem with
    g++ 3.3.3 compiler and libstdc++.so.5 library.
    With Very Best Regards
    Subrata Basak
    MediaRing Ltd., Singapore

    CVS differentiate text and binary files (they are marked as one or the other by using a CVS option when adding the file). If a file is marked as text, cvs will perform line-end conversion if needed.
    On Linux, line endings are coded as LF, whereas on Windows they're coded as CRLF. When you copied files from Windows to Linux, you probably did a binary copy, which left the CRLFs intact. When you checked those files into CVS on the Linux server, Linux CVS did not convert the CRLFs into LFs.
    The result of this is that if you check the files out on Linux, they will still contain CRLF (which is wrong for Linux). You may verify this by checking out a file on Linux, then opening it using vi -b. The CRs should show as extra ^M's at the end of each line.
    If, on the other hand, you check out the file on Windows, a conversion will take place, where all LFs are converted to CRLF. The result of this is that your file will contain CRCRLF at the end of each line.
    The best way to fix this is probably to check everything out on the Linux box, remove every CR from every file, then check everything back in again.

  • Hp stream 8 problem with hp officejet 150 printer

    Hi,
    I bought a HP Stream 8 tablet(5801ca) two weeks ago and just buy a HP Officejet 150 Mobile All-in-One printer (CN550A) to work with my tablet. This setup is moving in a truck on the road, but I have never been able to set it correctly. Both devices have a bluetooth connection and I installed the drivers correctly (maybe not) but tried again over and over.
    My problem is that I can connect the tablet with the printer, I see the printer correctly while printing documents, then I send the command to print, the printer starts up a printing cycle, but jam at the firt line. Nothing is printed and everything bug here. I have to restart both the printer and the tablet to be able to do something again with the printer.
    I tried many times with different settings and different installation drivers (with CD coming with the printer and with the driver on hp website). Always had the same problem, then I tought the printer was not good, so I returned it and had a new one, same model. Still the same problem.
    So is my tablet having a problem ? Or just some changes in a setting somewhere ? Or maybe, I can't even print on a HP Officejet 150 Mobile All-in-One (CN550A) with a HP Stream 8 Tablet (5801ca) by a bluetooth connection ?
    Any suggestion or help would be more than welcome,
    Thank you

    Hey @Max0m, 
    Welcome to the HP Support Forum.  
    I understand you're unable to print using your HP Officejet 150 Mobile All-in-One Printer.  I would like to help.  
    The following article from HP may resolve the issue for you.  Click on the heading below:
    HP Officejet 150 Mobile All-in-One Printer Series (L511) - Cannot Print through a Bluetooth Wireless...
    Try both solutions and if this doesn't pan out, I recommend you call our Cloud Services at 855-785-2777. If you live outside the US/Canada Region, please click the link below to get the support number for your region.
    http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html 
    Best of luck!  
    E-roq
    I work on behalf of HP.
    Please click Accept as Solution if you feel my post solved your issue, it will help others find the solution.
    Click Kudos Thumbs Up on the right to say “Thanks” for helping!

  • File XML Content Conversion: Problem with special characters

    Hello,
    in a file sender cc content conversion is used to transform a flat structure to XML. What we experiencecd is that the message mapping failed due to a character that was not allowed in XML:
    I was assuming that the file content conversion just creates XML messages with allowed characters. Is there any way to configure content conversion to remove control characters which are not allowed in XML? Unfortunately the sender system cannot be modified.
    Thank you.

    Hi Florian,
      Please use this UDF to remove special characters which prevent XML messages to form properly.
    public static String removeSpecialChar(String s)
              try
                   s=s.replaceAll("&","& amp ;");
                   s=s.replaceAll("<"  , "  & lt ;");
                   s=s.replaceAll(">", "& gt ;");
                   s=s.replaceAll("'", "& apos ;");
                   s=s.replaceAll("\"", "& quot ;");
              catch(Exception e)
                   e.printStackTrace();
              return s;
    Please remove spaces between characters within double quotes. I have added them because otherwise you can't see this code properly. Please check this below link , please replace the characters with proper values as the display is causing a problem here   
    http://support.microsoft.com/kb/316063
    regards
    Anupam
    Edited by: anupamsap on Jul 7, 2011 4:22 PM
    Edited by: anupamsap on Jul 7, 2011 4:23 PM

Maybe you are looking for

  • Adoby ID or password is incorrect??

    Hello, I'm sure I'm not the only one. I have an Ipad, I downloaded the adobe reader and want to share my PDFs with my other devices. I pressed the icon (that looks like a cloud with an arrow pointing upwards in front of it) that prompts "lets get sta

  • Convert Colors profile to threshold to black? [A9]

    Is there a reasonable way to create a color profile that can be used with Convert Colors to apply a threshold (180/255) function to convert an RGB PDF into a black-and-white PDF? Acrobat 9 (CS5), OSX 10.6.7. I have some multipage PDF files I want to

  • Syncing IE11 favourites bar TO my iPad Air

    How do I sync the IE11 Favourites Bar TO my iPad Air. When I do this, I only seem able to sync FROM the iPad and this overwrites the existing Favourites Bar on IE. I have the Favourites set up as I want them on IE11, but when I sync the iPad, they ar

  • Best way to use JAXB for this problem?

    I have an input XML which is very large and complicated. It comes with it's own schema I only need to extract a few parts of the data contained in that XML, scattered throughout the document. I care not about most of the XML file but I do care about

  • Data Mismatch: Plant level stock and Serial Number collection

    Hi, I am working with stock in SM. I want the plant level stock and the serial number collection for the serialised material. The value coming for the plant stock is 20 (Eg. MATNR = 50004050) and the corresponding serial number collection is 27. But