Stop Xalan Transform From Resolves Entities

I'm trying to write a DOM tree to an XML file, so I've been using Xalan to do a transformation. My code is quite simple:
DOMSource source = new DOMSource( domDocument );
StreamResult result = new StreamResult( new File( "out.xml" ));
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
transformer.setOutputProperty( OutputKeys.ENCODING, "utf-8" );
transformer.transform( source, result )
The problem is that my DOM document has character entity references that the transformer seems intent on converting. For example XML that looks like this in the DOM tree:
<value>Here is a weird character: &eacute;</value>
Gets output like this in the xml file:
<value>Here is a weird character: ?</value>
Since I'm not actually transforming anything, just outputting the XML, I need to preserve any character entity references. Oddly enough the source XML file contains the &amp; entity, which gets converted to a regular & character when the file is parsed into the DOM tree. It's the only character entity that isn't stored as an actual EntityReference object in the tree, but the only one that gets converted back to &amp; on a transform. Any help would be greatly appreciated.

Yes, the character entities are declared in the DTD. At one point in development I was including it with:
transformer.setOutputProperty( OutputKeys.DOCTYPE_PUBLIC,domDocument.getDoctype().getPublicId());
transformer.setOutputProperty( OutputKeys.DOCTYPE_SYSTEM,domDocument.getDoctype().getSystemId());
transformer.transform( source, result );
(I'm writing this code from memory; sorry if there are any syntax errors)
The code compiled and did correctly add the DOCTYPE entry to the file, but the references are still being converted. It does matter for us that the references remain intact. Eventually the XML will go into a publishing system that uses a different set of proprietary character codes for that software; utf-8 won't work :-(

Similar Messages

  • Stop escaped characters from resolving within String class.

    Hello,
    Is it possible to stop escaped characters from resolving within the String class?
    For example, I define a character array,
    char[] c = {'0','\\','n'}
    and I want to create a String based on this exact sequence (0\n). However, when I call the String constructor String(char[]), it resolves the \n sequence into the newline character, creating a String of length 2 not 3.
    I'm not very familiar with the innards of the Java compiler (does "xyz" translate to char[]{'x','y','z'}?), so maybe this is something very basic.
    Does anyone know if there is a flag that can be set somehow before I create a String instance (it appears that no String constructor supports this kind flag)?
    Or perhaps is there a method in the standard Java release that escapes all escape characters in a character array...? I'm curious if there is a simpler way (like a flag), because the method approach seems superfluous.
    Thanks,
    Brien

    What do you mean?char[] c = {'0', '\\', 'n'};
    String s = new String(c);
    System.out.println(s);does give the string 0\n...
    And by the way, it's not the String class that transforms \n to the linefeed character, it is the compiler..

  • How do I stop Aggregate transform from doing inappropriate rounding

    We have a client that is sending us files where amounts are in different records like this:
    clientID, productID, amount
    123,1,24.00
    123,2,28.00
    123,3,29.00
    We then take these three records and turn them into one record
    ClientID, product1Amt, product2Amt, product3Amt
    123,24.00, 28.00, 29.00
    The dev before me, did this by using the aggregate transform. The problem is, the transform is somehow adding magic numbers that didn't exist before. Amounts will go in looking like this:
    3333.33
    and come out of the transform looking like this
    3333.330078125
    The column comes off a flat file as a float. The destination table column is of datatype money. When it hits the table, it turns it into:
    3333.3301
    In some cases I've seen it turned into:
    3333.3299.
    Neither is acceptable but I don't know how to control it. Any suggestions?

    What is the acceptible value?
    You need then use a data conversion transformation and convert the incoming data to DT_CY then use it in the aggregate.
    If the aggregate does not still work then use the Script Transformation and do the calculation in code inside the
    ProcessInputRow method:
    Arthur
    MyBlog
    Twitter

  • Stop Xerces to resolve Entities

    Hi,
    1) Question:
    ============
    I've got the following problem. In one of my swing-projects i need the possiblity to edit XML-Code. Now when reading in the XML-File Xerces expands ENTITITES like &amp; and in my Swing-App only & is shown. I have not found a property or something like this to prevent Xerces from expanding the entities. Does anybody know how to do this?
    2) Question:
    ============
    At the moment I have solved the problem from above by using the xml-Parser which comes with java-1.4. It does not expand Entities when setting
    -----------------cut----------------------
    factory.setExpandEntityReferences( false );
    -----------------cut----------------------
    Now there's the problem. For some of the XML-Files I need Schema-Validation which could only be done by Xerces (am I right?). Still at the moment when I add the xercesImpl.jar to my classpath the sun-parser does not resolve entities any more. Does anybody know what's going on there?
    thx
    tom

    XML does not allow & by itself to appear in a text node. The rule is that it must be escaped, i.e. you must put &amp; when you want that ampersand character. That rule, however, only specifies how the ampersand character must appear when it is in an XML file. When it is extracted from the XML file by software, Xerces or other, it will be treated as an ampersand.
    So that's the rule. Presumably what you said about "expanding entities" was a confusion of that rule, but I couldn't really tell.
    Anyway, what your Swing app should display for the ampersand character depends on what it is designed to display. If you are just putting raw XML into a text box and allowing the user to edit it, then you should put valid XML there, and that means the escaped version (&amp;). But I wouldn't recommend that approach, because humans are likely to violate XML rules, like the escaping rule for example and many others. You are likely to end up with malformed XML if you do that.
    However, if you have something like a tree structure with an element or an attribute at each node, then you should certainly display the unescaped version (&). This is what you will get when you extract a text node from a DOM anyway, and it's a correct representation of what is actually in the XML file from the user's point of view.
    That's how you should treat the ampersand character, in my view. But the escaped ampersand character is normally not considered to be an entity. If you are declaring it as an entity in your schema, perhaps you should not do that as it seems to be leading to a lot of confusion.

  • How do I stop my photos from disappearing?

    LG G3 - I took many photos over the weekend. While I was looking at the gallery Sunday night, the gallery images started suddenly showing with gray bars on photos, then suddenly turning into a question mark icon like the phone had no idea what the file was.
    the phone has always worked fine, and I have never had any problems before. I have not installed any new updates or apps recently. I have no third party photo manager - just use the gallery and associated apps that came with the phone. I do not use Google+.
    Every time I look at the phone, more of my photos are replaced with the ? icon. If I take a new photo, I can look at the photo within the camera and see it fine. I can open the gallery and see the photo fine. Then suddenly, the gray bar will appear on the image and it will change to the ? icon.
    I have done the following troubleshooting:
    1. rebooted my phone.
    2. Shutdown the phone, and let it sit off for 2 minutes, then restarted the phone.
    3. Shutdown the phone, took out the battery, and let it sit for 2 minutes, then restarted the phone.
    4. unmounted the SD card, shutdown the phone, took out the SD card. replaced the SD card and restarted the phone.
    5. verified that the camera is storing photos to the SD card
    6. Changed the camera storage to memory, and back to SD card.
    Any suggestions on how to stop my phone from being confused and realize that the files it seems to not understand are actually the photos I took with the camera on the device, and that it really did understand all of the photos at one time?
    I do not have the ability to plug my microSD card into my PC. My PC does not have a micro slot and I do not currently have the ability to go buy an adapter
    If your advice is anything like "should have backed up the phone" your condescending input is not needed. This is not a backup issue, this is an issue with the phone forgetting what photos are.

        Oh goodess hammer1959! Let's see what's going on with your phone. I really apppreciate all the details you've provided so far. Please try clearing cache in the camera to see if this gets resolved. When completed, please restart phone. http://vz.to/1s5uICj
    Thank you,
    VanessaS_VZW
    Follow us on Twitter @VZWSupport

  • How do I stop my itunes from saying my session has timed out when i'm trying to download a song

    How do I stop my itunes from saying my session has timed out when i'm trying to download a song

    What troubleshooting steps have you tried so far?
    Basic Troubleshooting Steps when all else fails
    - Quit the App by opening multi-tasking bar, and swiping the App upward to make it disappear.  (For iOS 6, holding down the icon for the App for about 3-5 seconds, and then tap the red circle with the white minus sign.)
    - Relaunch the App and try again.
    - Restart the device. http://support.apple.com/kb/ht1430
    - Reset the device. (Same article as above.)
    - Reset All Settings (Settings > General > Reset > Reset All Settings)
    - Restore from backup. http://support.apple.com/kb/ht1766 (If you don't have a backup, make one now, then skip to the next step.)
    - Restore as new device. http://support.apple.com/kb/HT4137  For this step, do not re-download ANYTHING, and do not sign into your Apple ID.
    - Test the issue after each step.  If the last one does not resolve the issue, it is likely a hardware problem.

  • How do I stop the cursor from spontaneously going to Line one space one in Notes?

    How do I stop the cursor from spontaneously going to Line one Space one in Notes?
    I am currently working on a MacBook Pro connected by Wi-Fi or Blue Tooth to my 16GB iPhone 4S; and supposedly to iCloud.  I install every upgrade on each computer till the computer can take no more.  My current MacBook Pro continues to accept upgrades.
    I have been dealing with Address Book foibles since it first came out and the problems seem to get worse rather than resolved.
    Problem #1: When a Company Name is checked to take precedence over a personal name the record/file does not surface during searches.  This has happened for years on all my Macs, including most recently my MacBook Pro and its predecessor PowerBook G4.  How do I fix this?
    Problem #2: The Printing Defaults for Address Book Files are not useful and I can find no way to change them to my own preferences once and for all.  I must reset them for every file every time I choose to print a file.  Is there some way to set the defaults to MY preferences and only occasionally reset them according to my needs?
    Problem #3:  When entering information in "Notes" the cursor randomly and spontaneously goes to line one space one as I am entering information.  How do I stop this?  Then when I cut and paste the misplaced text to where it belongs it may or may not return to once again begin at line one space one and following.
    Problem #4:  When Printing a Record/File from Address Book I would like to use the whole 8.5" x 11" page.  Instead it prints on an 8.5" x 11" page in three columns.  Is there a way to format the output?  I have not found one and the Mac 'Geniuses' do not know of any.
    Problem #5:  Subsequent to one of the upgrades in the last year or so, the search feature does not work.  (I have had this computer since May 2011).  No matter what I type in the search line I am stuck in the 'All' Directory.  To find anyone or anything I must scroll through the address book manually.  Is there a fix to this?
    Problem #6:  Sometimes, when I try to sync my MacBook Pro and my iPhone, the records simply duplicate.  How d I undo this without manually deleting the duplicates?
    Problem #7:  Does anyone know of a third party Address-Book-type App that is better than the Apple version and can easily import over 3000 contacts information?

    '''I had the same problem when I updated to firefox 4. This is how i fixed it:'''
    The problem seems to be caused by the 'New Tab Homepage' add on. So:
    # Disable or remove the 'New Tab Homepage' add on and restart firefox.
    # Download and install the firefox add on called 'NewTabURL' and restart firefox.
    # Click on the Options button for NewTabURL and uncheck 'Select location bar after loading new tab'
    # Under the 'Default URL for new tabs' heading, choose 'Home Page'
    # Click on the Save button.
    Hopefully, problem solved!

  • How do I stop my ipad from referencing an old apple id?  My old ID was deleted by an Apple representative months ago.  When I try to "update" my ipad it always references my old apple id which I no longer have a password for..help

    How do I stop my ipad from referencing an old apple id?  My old Apple ID was my old email address.  I contacted Apple and it was deleted by an Apple representative months ago.  Whenever I try to "update" my ipad (games etc.)  it always references my "old apple id" which I no longer have a password for or have any access too..help

    Problem is...I do NOT know the password for this "old" apple id.  I haven't used this apple id in over 1 year and it "suddenly" started to show up.  I can NOT update or down load any updates without knowing the old apple id's password either.  I am getting help.  I was able to contact tech support and they are in the process of helping me within an email reply to "reset" my password from that old Apple id, in the next 24 hours.           
    Thank you all for your help!  I hope we are able to resolve this issue.  Again, it is very odd that my "old" email or original Apple ID decided to appear after such a long span.  I will keep you all posted as to how it was resolved when I hear back via an email.

  • Org.apache.xalan.transformer.TransformerImpl

    I have an ecr.index servlet which is run on Tomcat, here is the part of it's code:
               javax.xml.transform.sax.SAXTransformerFactory factory = ( javax.xml.transform.sax.SAXTransformerFactory ) javax.xml.transform.TransformerFactory.newInstance();
               Source ss = new StreamSource( new FileInputStream( context.getRealPath( xsl_file ) ) );
               ss.setSystemId( context.getRealPath( xsl_file ) );
               javax.xml.transform.sax.TransformerHandler handler = factory.newTransformerHandler( ss );
           131:handler.setResult( new StreamResult( response.getOutputStream() ) );When I access the page the exception is thrown:
    org.apache.xml.utils.WrappedRuntimeException: The output format must have a '{http://xml.apache.org/xalan}content-handler' property!
         at org.apache.xalan.serialize.SerializerFactory.getSerializer(SerializerFactory.java:142)
         at org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:1048)
         at org.apache.xalan.transformer.TransformerImpl.createResultContentHandler(TransformerImpl.java:975)
         at org.apache.xalan.transformer.TransformerHandlerImpl.setResult(TransformerHandlerImpl.java:209)
         at ecr.index.service(index.java:131)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
         at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
         at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
         at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
         at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:339)
         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:415)
         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:716)
         at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:650)
         at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:829)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
         at java.lang.Thread.run(Thread.java:534)But I don't use org.apache.xalan.transformer.TransformerImpl, even the package org.apache.xalan.transformer isn't imported, but this package is present in classpath, where is the error?

    Here is the reason for this problem....
    JDK 1.4 comes with a version of Xalan...
    Somewhere around 1.4.2_03 the Xalan version that shipped with the JDK was upgraded because the XSLT spec was completed/revised or something like that.. When this happend the namespace identifier for xalan custom 'tags' changed. The content-handler tag used to be in the xslt name space.. now it is in the xalan namespace.
    Problem is many stylesheets don't specifically set the output format so the defaults are used and the values are initialized from a properties file. However.... and this is where the problems comes in...
    The Namespaces are used as prefixes to the keys in the file... AND... Tomcat''s WebappClassLoader is not safe about ensuring that a resource is loaded from the same Jar file as the classes that use it....
    So what is happening is... the Xalan from your JVM is being used... but it is loading the formatting properties from a Xalan that is included in your Webapp.... which of course don't match....
    All you need to do is remove the xalanXXX.jar from WEB-INF/lib and this problem will go away...
    Matt Brozowski
    The OpenNMS Group, Inc...

  • Iphone has stopped synching calendars from Outlook, why?

    iphone has stopped synching calendars from Outlook, why?  What settings should I check?

    Hello djm29mi
    Check out the article below for troubleshooting syncing issues with Outlook. If it is still not resolved, look for the advanced troubleshooting steps for even further troubleshooting options.
    iPhone, iPad, iPod touch: Troubleshooting contact and calendar syncing via USB on Windows
    http://support.apple.com/kb/HT1692
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Hold a start frame or copy transformation from one object to another

    Hi There,
    I have some stop-motion clips that are in the timeline and are reversed. When I play the timeline, these items move out of frame.
    However, only the movement is animated and I need them to be on screen before they move off. Can you hold a start frame so that the stay on screen until they animate?
    If not, I have a still of the frame I would like to hold but can't figure out how to copy the transformations from the animated clip to the still so they match perfectly. How do you do this?
    Any help would be appreciated.
    Cheers
    Ben

    Ended up copying and pasting the transformations by hand which was very painful as there seems to be a big with copying and pasting transformations between objects.
    You have to click in the box, hit the arrow key, select all, copy, click in the box for the next object, hit the arrow key, select all, paste.
    If you just click the box for the fist object, copy, click in the next box for the next object and paste, nothing happens!

  • How can i stop deleted gmails from reappearing?

    how can I stop deleted gmails from reappearing?

    Ignore him!  Syncing will not solve this.
    if this just started, it may also resolve on its own.   A reboot may resolve it quicker.
    When you delete, are you confirming the delete by taping "done" Or "delete"?

  • PC Suite stops Microsoft Fax from working

    The fax server information cannot be retrieved
    I have just downloaded and installed the latest version of PC Suite.
    Each time I install the recent versions of PC Suite it stops Microsoft fax from working.
    I am running windows XP SP2
    I have a Nokia 5310
    The error message is:
    The fax server information cannot be retrieved
    The fax wizard will now close.
    I can use an earlier version of PC Suite but then my phone is not fully supported.
    Any ideas?

    Thanks for your response Miksu. You have pointed me to the right place. It is the connection manager that fails to recognise the BT stack that causes my problems. This is always resolved by a repair. It seems that the order of initiation is very important which may be why Luist has started to have the problem.
    In my experience, once things stop to work, I've had to strip out any subsequent installs.
    My PCSuite also stopped working after it installed cable connection manager (or something like that) without me asking. I found it in Control Panel->Add/Remove programs. I removed it and PC Suite started to work again, so I completely removed PC Suite then re-installed, and allowed it to add the relevant devices relating to my phone (about 4 devices alltogether) but alas this did not solve my "return from standby" issue. I think I need to remove PC Suite and then Bluetooth, and maybe something else before re-installing - I'll leave that for a rainy day.
    Thanks again Miksu

  • MY envy 5330e has stopped printing anything from online sources.

    MY envy 5330e has stopped printing anything from online sources but will print from on board documents or pictures.

    Hey @youngfmly,
    Because your HP ENVY 5530 e-All-in-One Printer is producing blank prints from three computers when printing from the the internet I'm wondering if there may actually be a hardware ink system issue occuring. I understand that this may sound odd as everything else appears to print fine. However, when printing from your computers colour ink is used to enrich the black ink when printing in certain programs. Primarily when the computer 'sends' the print job to the printer as an image file. Therefore, just to ensure that your printers ink system is functioning properly, I am going to have you print a standalone Print Quality Report.
    How to Print the Quality Report:
    Load plain white paper in the paper tray.
    On the printer control panel, touch the Settings icon (), and then touch Tools. The Tools Menu displays.
    Touch Print Quality Report. The printer prints the test page.
    If this report prints perfectly: Than the issue that you're experiencing is not related to the printer. Rather, there is likely a setting that still  needs to be checked under Google Chrome. If your modem/router was causing this issue all prints would be affected.
    If this report prints with quality defects or missing colours: Than the Google Chrome printing issue that you're experiencing is being caused by your printer. To resolve this print system issue can I please have you click here. Once the support document opens please run through Solution six, Solution seven, and Solution eight. This includes any sub-steps under the listed Solutions.
    Please let me know the result of printing this standalone Quality Report. I look forward to hearing from you!
    X-23
    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 the "Kudos, Thumbs Up" on the right to say "Thanks" for helping!

  • Mail has stopped retrieving messages from Yahoo

    Mail has stopped retrieving messages from Yahoo email account.  I deleted the account, cleared Safari history and recreated the account.  Successfully retrieved all folders and contents of folders but no messages.  Watching the Activity, it appeared to be retrieving the messages but none appear.  Looking at the log, I can see FETCH error server.  Not sure where to go from here to resolve the issue.  Thanks for your help.

    Based on what I've read in the forum, Yahoo mail has been having some problems.
    Mail troubleshooting - Yosemite
    What does Mail/Window/Connection Doctor Show? If the server is red, select it and look at the Show Details box.
    Troubleshooting sending and receiving email messages
    Troubleshooting sending email messages
    SMTP servers keep going offline

Maybe you are looking for

  • Variable in report painter

    Hi, I have a customized variable in report painter which pulls data from standard table, profit centre (GLPCT).  The data is included dummy profit centre.  How can block or should not allow dummy profit centre data to flow to the report? Please advic

  • How to delete an email address in Mail

    A friend of mine has just changed his email address but I cannot remove his old one from Mail. I have added his new address and removed the old one from my Address book but his old address still comes up as the default when starting a new email to hi

  • Lawyers: Trouble with ECF PACER and ECF after 10.5.7 update!

    I work in a high volume law office dealing with bankruptcy work. After updating to Mac OS 10.5.7, both Safari and variations of Mozilla/Camino/Firefox are unable to select multiple events when filing a case (ex. lift the automatic stay AND lift the n

  • Can I choose which screen (page) apps download to on my iPad?

    Is there a way to choose this, or does the iPad automatically decide?  If it decides, how can I tell in advance which screen apps will download to?

  • Revel in Lightroom 4

    Hi! Just downloaded Lightroom 4 and signed up for Revel. But is it possible to view the Revel pictures in Lightroom? I know you can export to revel but i cant view pictures in Revel uploaded from other devices, is this something Adobe i working on? K