Problem transforming SAX events

The following code parses a CSV file creating SAX events. If no XSL file is passed, it correctly does an identity transform and creates output so my assumption is that the parsing is working OK. However if I pass an xsl file containing the identity transfromation, I get no output and no exceptions. This is frustrating. Any ideas would be appreciated.
String csvFileName = args[0];
String xsltFileName = (args.length < 2)?null:args[1];
TransformerFactory tranFactory = TransformerFactory.newInstance();
tranFactory.setErrorListener(new SimpleErrorListener());
if (!tranFactory.getFeature(SAXTransformerFactory.FEATURE)){
System.out.println("SAXTransformerFactory is not supported");
System.exit(1);
SAXTransformerFactory saxTranFactory = (SAXTransformerFactory)tranFactory;
TransformerHandler tranHandler = null;
try{
if (xsltFileName == null){
tranHandler = saxTranFactory.newTransformerHandler();
else{
StreamSource s = new StreamSource(new File(xsltFileName));
tranHandler = saxTranFactory.newTransformerHandler(s);
catch(javax.xml.transform.TransformerConfigurationException e){
e.printStackTrace();
System.exit(1);
try{          
FileWriter f = new FileWriter(new File(xsltFileName+".out"));
StreamResult r = new StreamResult(f);
tranHandler.setResult(r);
CSVXMLReader reader = new CSVXMLReader();
reader.setContentHandler(tranHandler);
reader.parse(new InputSource(new FileReader(csvFileName)));
f.flush();
}

first problem solved. The parse method was missing endDocument().
Now i get the following Exception:
java.lang.NullPointerException at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3174) at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
at dpak.xml.CSVXMLReader.parse(CSVXMLReader.java:71)
at dpak.xml.CSVXMLReader.main(CSVXMLReader.java:120)
I am using XML Winter Pack release with xalan.jar and xerces.jar in the jre/ext directory.
Stuck again. Any help would be appreciated.

Similar Messages

  • XSL problem with javax.xml.transform.sax.SAXTransformerFactory

    Dear sirs,
    I use SAXTransformerFactory in order to transform a Hashtable to SAX Event and apply a XSL.
    I try this code with the lastest version of apache parser.
    It run well.
    But, I put this software to WEBLOGIC 6.2 server and no run.
    this check is true:
              if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
    Some one can help me.
    Thank in avance
    The code:
    java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
              com.cajarural.xml.HashtableParser parser = new com.cajarural.xml.HashtableParser(hashtable);
              // Codigo para el TansformerHandler
              // set the destination for the XSLT transformation
                   javax.xml.transform.TransformerFactory transFact = javax.xml.transform.TransformerFactory.newInstance();
                   if (transFact.getFeature(javax.xml.transform.sax.SAXTransformerFactory.FEATURE)&&transFact.getFeature(javax.xml.transform.sax.SAXSource.FEATURE))
    javax.xml.transform.sax.SAXTransformerFactory saxTransFact = (javax.xml.transform.sax.SAXTransformerFactory) transFact;
    javax.xml.transform.sax.TransformerHandler transHand = saxTransFact.newTransformerHandler(templates);
    transHand.setResult(new javax.xml.transform.stream.StreamResult(bout));
    parser.setContentHandler(transHand);
    // attach the XSLT processor to the           parser.parse();
              return new String(bout.toByteArray());

    put Xalan in your war file then try using this kind of commands:     System.setProperty("org.xml.sax.parser", "org.apache.xerces.parsers.SAXParser");
    System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
    System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");This tells JAXP what implementations it should use without even asking your administrator to modify the WebLogic setup...
    It's what I've done with the WLS7.0 server I am using ;-)

  • What to do with SAX events

    I want to iterate over a database recordset and generate sax events to create a virtual xml document. But I'm struggling to see how the events are consumed.
    What do I do with the events that are generated by the strart/end document and element handlers. How do I send to a file, or better still, pass the events onto some tool to output as html/xml pages?
    Cheers again
    -thanks 4earlier code @Trejkaz

    All the examples I have ever seen of SAX are like this:
    You take an XML document and give it to a SAX parser. The SAX parser turns it into a stream of SAX events and calls your handler's startElement() etc. methods, which generally write to a file or something like that.
    Your requirement is the reverse, namely you want to input from the "something like that", make a stream of SAX events, and have those turned into an XML document. I have never seen a decent example of this so I had to work it out for myself. I posted my solution in this forum several months ago but I can't find it now. So here it is again:SAXTransformerFactory factory = (SAXTransformerFactory)TransformerFactory.newInstance();
    TransformerHandler handler = factory.newTransformerHandler();
    // if you want to use XSL to transform what you produce then
    // you need the version that takes a Templates argument.
    handler.setResult(new StreamResult(response.getWriter()));
    // in my case I send the resulting XML document to the servlet
    // response, but you could send it somewhere else.
    SAXParserFactory spf = SAXParserFactory.newInstance();
    XMLReader reader = spf.newSAXParser().getXMLReader();
    reader.setContentHandler(handler);
    reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
    reader.setFeature("http://xml.org/sax/features/namespaces", true);
    reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
    handler.startDocument();
    startElement(handler, "Doc");
    // I am producing an XML document whose root is a Doc element.
    // Send more SAX events here.
    endElement(handler, "Doc");
    handler.endDocument();

  • Problem in SAX XSD schema validator

    hi
    I've tried this code to validate XML using xsd file:
    public static void validate(String xmlFilePath, URL schemaFileUrl)
            try
                SAXParserFactory factory = SAXParserFactory.newInstance();
                factory.setValidating(false);// stop standard validation to allow
                                                // custom schema
                factory.setNamespaceAware(true);
                SchemaFactory schemaFactory = SchemaFactory
                        .newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
                factory.setSchema(schemaFactory.newSchema(schemaFileUrl));
                SAXParser parser = factory.newSAXParser();
                XMLReader reader = parser.getXMLReader();
                // Register the error handler
                reader.setErrorHandler(new JS_ValidationError());
                // Parse the file as the first argument on the command-line
                reader.parse(xmlFilePath);
            catch (SAXException e)
                System.out.println("Error: " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e)
                System.out.println("Error: " + e.getMessage());
                e.printStackTrace();
            } catch (ParserConfigurationException e)
                // TODO Auto-generated catch block
                e.printStackTrace();
        } I have called this method ,but it issues this error :"unknown protocol" followed by windows partition name, in the debug I found that the value of the url is "*file://(*windows-partiton-char)/rest of path" !!!
    this should work but it doesn't!!
    so how can I fix this problem?
    thanks

    someone sent me this code to fix,it works:
    package schemaValidationPackage;
    * XsdSchemaSaxValidator.java
    * Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
    import javax.xml.validation.SchemaFactory;
    import javax.xml.validation.Schema;
    import javax.xml.XMLConstants;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.transform.sax.SAXSource;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import javax.xml.validation.Validator;
    import java.io.*;
    import java.net.URL;
    //also thanks for developer Hind Abd-El-Khalek
    public class XsdSchemaSaxValidator {
         public static void validate(String xmlFilePath, URL schemaFileUrl)
            try
                SAXParserFactory factory = SAXParserFactory.newInstance();
                factory.setValidating(false);// stop standard validation to allow
                                                // custom schema
                factory.setNamespaceAware(true);
                SchemaFactory schemaFactory = SchemaFactory
                        .newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
                factory.setSchema(schemaFactory.newSchema(schemaFileUrl));
                SAXParser parser = factory.newSAXParser();
                XMLReader reader = parser.getXMLReader();
                // Register the error handler
                reader.setErrorHandler(new JS_ValidationError());
                // Parse the file as the first argument on the command-line
                reader.parse(xmlFilePath);
            catch (SAXException e)
                System.out.println("Error: " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e)
                System.out.println("Error: " + e.getMessage());
                e.printStackTrace();
            } catch (ParserConfigurationException e)
                // TODO Auto-generated catch block
                e.printStackTrace();
      public static void validateXml(Schema schema, String xmlName) {
        try {
          // creating a Validator instance
          Validator validator = schema.newValidator();
          // preparing the XML file as a SAX source
          SAXSource source = new SAXSource(
            new InputSource(new java.io.FileInputStream(xmlName)));
          // validating the SAX source against the schema
          validator.validate(source);
          System.out.println();
          System.out.println("Validation passed.");
        } catch (Exception e) {
          // catching all validation exceptions
          System.out.println();
          System.out.println(e.toString());
      public static Schema loadSchema(String name) {
        Schema schema = null;
        try {
          String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
          SchemaFactory factory = SchemaFactory.newInstance(language);
          schema = factory.newSchema(new File(name));
        } catch (Exception e) {
          System.out.println(e.toString());
        return schema;
    }

  • I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?

    I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?  Any help will be appreciated.  Thank you.

    This should give you some good insight, I'd probably store them on an External HD on the old machine and then just drag and drop to the new machine.
    https://discussions.apple.com/docs/DOC-4141

  • Ps CS6 Problem: Transform applied to Smart Object fails to transform an attached Smart Filters Mask

    Ps CS6
    OSX 10.6.8
    Problem: Transform applied to Smart Object fails to transform an attached Smart Filters Mask.
    I mean a Transform, including Free Transform, as found in the Edit menu.  A simple move by the Move Tool is OK.
    A workaround until this bug is squashed is to encapsulate the Smart Object + Smart Filters + Filter Mask inside another Smart Object and transform that.
    However, that will not be a satisfactory solution in some cases. If a filter has size parameter(s), e.g. Gaussian Blur radius, a scaling or warping/distorting transform applied after the filter will obviously differ from the filter applied after the transform.
    In any case, the workaround is inconvenient to subsequent editing and experimenting with filters and masks.

    R_Kelly wrote:
    I don't think that's a bug since the implementation seems to be purposely done.
    It's been that way since photoshop cs3.
    If its been like that since CS3 then I think it's a bug which remains because nobody (or not enough people) has complained before.

  • ICal error "There was a problem receiving this event invitation"

    Whenever I try accepting an event invitation I get a dialog prompt that says
    *There was a problem receiving this event invitation*
    Someone invited you to an event using an email address that isnt on your "me" card in Address Book. Find your email address in the following list and add it to your card in Address Book
    Problem is I've done that, my vCard is up to date. It was working fine, I cant recieve any invites anymore, wether they come from OSX or Windows. Can anyone help?

    I ran into this same issue. To resolve this, go into the Address Book application. Select the vCard that is "your" card. Now in the menu bar, go to "Card". On the drop down menu, select "Make this my card". You should now be able to accept iCal invitations without any issues. When I upgraded to 10.5.1 the issue came back and this method seemed to resolve it.

  • How do I identify a problem in an event?

    Friends,
    I've updated to FCP X 10.1.  An event that I created after updating and for which I created a project suddenly displayed a yellow hazard symbol next to the name of the event.  This suggests that there is some sort of problem with the event or project.  How can I identify more specifically what the problem is?  Everything looks good when I look at the event and enclosed project.
    Thanks!
    Steve

    It means at least one peice of media is offline, and needs to be relinked.
    Select the Event, go to File > Relink Files, then swith from All to Missing Files.  You can then relink anything that is offline.

  • Problem Transforming

    Hi All,
    I am facing a problem transforming an XML document using XSLT.
    I have two XML documents.One is the source document. In the XSL i refer to another XML document which is in the same folder as the source document using document() function.(My XSL is in a different folder).But i get error stating the XSLT Engine could not load the document.(Since it searches for the second document in the same folder where XSL is placed).
    I tried using two argument document function one that takes in base URI as one of the arguments.But that failed too.
    To be more clearer
    My directory structure is as follows
    folder1
    - a.xml
    - b.xml
    folder2
    -convert.xsl.
    And now the source document for transformation is a.xml
    and in convert.xsl i would like to refer to b.xml using document() fnction, which i am unable to.
    I am using JDK1.4.1
    Regards
    Sathya

    give a full URI in document() : file://whatever

  • At event calendering site, getting message "There was a problem with your event submission. If you have disabled JavaScript please enable it and try your submission again." Javascript is ENABLED on my computer.

    I'm trying to submit an event to the events calendar at http://calendar.jtnews.net/events/index.php?com=submit. After I enter the Authentication words and press Enter, I get the message, "There was a problem with your event submission. If you have disabled JavaScript please enable it and try your submission again." According to my Firefox/Tools, etc., button, Javascript is enabled. I

    Hello mjswooosh,
    I'm very disheartened to hear that you've had ongoing problems when attempting to order from BestBuy.com. Our goal is ever to provide a fun and efficient shopping environment! Certainly creating aggravation serves neither you nor us and I apologize sincerely for this having been your experience.
    We recommend the troubleshooting steps you mentioned (i.e., clearing the browser cache, deleting temporary internet files and cookies) because this is the most common cause of this type of problem. I too have encountered this issue from time to time and these steps have almost always resolved the problem. I say almost always because there's one further step you can try: ensure that you have signed out of BestBuy.com, then perform the browser maintenance steps we've recommended. Afterward, before signing in to BestBuy.com, add your desired items to your cart and sign in as part of the checkout process. When the standard steps have not netted a resolution for me, this has solved the problem each time.
    I hope this helps. I'm very grateful that you took the time to write to us with your concerns and for sharing your very valuable feedback about your online experience.
    Sincerely,
    John|Social Media Specialist | Best Buy® Corporate
     Private Message

  • Problems with close event scripts and closing Photoshop

    Hi!
    We are having problems with close event scripts ("Cls ") when closing/quitting Photoshop.
    The close event scripts are working without problem when closing an image. But when quitting Photoshop without having closed all images we are observing the following behaviour:
    with CS2 the close event scripts are not triggered at all
    with CS4  the close event scripts are triggered and executed correctly. But after that the Photshop process freezes. No visible GUI, you have to kill the process with the task manager.
    I can reproduce this behaviour even with a small script consisting of a single alert('hello') and even an empty script. Is this an known bug or am I doing something wrong?
    Thanks for your help!
      Eric

    Check your energy saver settings under system preferences. That is where you set sleep setting.

  • Ps CS6 Problem: Transform applied to Smart Object cannot be repeated on another target

    Ps CS6
    OS X 10.6.8
    Problem: Transform applied to Smart Object cannot be repeated on another target.
    "Edit > Transform > Again" fails to transform any target after a Transform is applied to a Smart Object. The following message appears:

    When ever I have a problem in CS6 and I have many I always test priot releases like cs2 cs3 cs5.  I nevet nitice before you posted this problem the Photoshop has different favlors of Free Transform and that free transform for CS6 has been modified.  Adobe seems to be introducind new improvement matche with new bugs, 
    Investgating your bug using CS5 I see the following.  There are two types of free transform one type seems to be for smart Object layers and the other for other layer types.  In CS5 you should see a difference in the Option bar for Free transform.
    The option bar for layers other then smart object looklike this:
    Transform 9 anchor point icons  X: field Relative icon Y: filed  W: % Constrain icon H: %  Angle ° H: ° V: °
    The Option Bar for Smart Object layers look like this:
    Transform 9 anchor point icons  X: field Relative icon Y: filed  W: % Constrain icon H: %  Angle ° Check Box Anti Alias (grayed out)
    If I use the one for other then smart object layers Transform Again is not gratey out and I can use Transform Again on layers even smart object layers However the anchor point seems to be relative always to the first transformed layer's anchor point
    If I use free transform on the smart Object Layer and not have done any transform on a other then smart object layer in this Photoshop session not even in an other document the smart object layer will be tramsformed and Transform again menu item will be grayed out. If any had done a Transform on an layer other then smart object layer even in an other document Transform Again would not be grayed out and could be used on the smart object layer at hand.  The transform would not be the one just done on the smart object layer rather it be the one done to the other then smart object layer.  Seems a bit bazzar to me.  This may be how CS6 is also working.
    CS6 also added interpolation method to the other then Smart object layer transform and not the one for smart object layers. To be consuitant Adobe should have also put interpolation into the omart opject transform for Adobe transforms smart opject layer by first rendering the pixels for the smart opject then transforms them like a raster layer.  Adobe did manage to record the interpolation use into an action step.  However I do not know if the made it into Scripting  it did not make it into the photoshop javascript user guide. I will test the scriptlistener plugin to see if it records it for the action manager....
    Message was edited by: JJMack
    I have now tested the Scriptlistner Plugin it does record the interpolation for transform normal layers. Still the layer resize method in the Photoshop Javascript user guide has not been change for that support. In the past what I have done is scripting was to save the users default interpolation Photoshop prenerenvr changed the preference to what I wanted to use do the layer transform resize then restored the users interpolation preferance.  Adobe broke that in CS6 if the users defalt preference is what Adobe's defalt is "Bicubic Automatic" an internal Photoshop error occurs. Adobe did not add "Bicubic Autoimatic" to scripting when I try to save the preference scriping has the internal error. There is also no way to set the preference back to "Bicubic Automatic.  I'm also transform smart object layers so I would still have to use the save preference, change preference, transform, restore preferance method.  This works if the users preference is set to some preference other the "Bicubic Automatic"
    Message was edited by: JJMack
    So to me it look like CS5 and CS6 transform work basiclly the same.  There seems to have been some behavior changes made to CS6 I can not seem to put my finger on as well as the addition of the interpolation method in the option bar. I can't put my finger on it so it may be the same in CS5 and CS6.
    It may have to do with the bazar behavior of Free Transform  and Transform Again not being available on smart object layers if no free transform to a normal layer has been done in this Photoshop session  but are available if one was done in any doument. And thet you can start to do a transform on the smart object layer and see the Transform handle but then start using transform Again shortcut Ctrl+Shift+T and watch the old transform being done perhaps rotating some virtual anchor point and not around the acnchor point bing displayed in the Transform bounding box and control points.
    Message was edited by: JJMack
    Over in the Adobe Feedback site several issues were posted with CS6 Transform one was marked "Not a problem" by Adobe. One was marked "Solved" by Adobe and the others have no Adobe markings the may on not be a problem
    So I beleive there is a bug but I do not think it originated in CS6 the bazar things I see happing also seem to be in CS5.

  • SCOM-Difference between Problem Count and Event Count in Application Failure Analysis Report

    Dear All, 
    Could someone explain me clearly , the difference between  Problem Count and
    Event Count in Application Failure Analysis  Report. Please help me in understanding What is meant be problem and event in the report .
    Thanks in Advance.
    Regards,
    Rajesh Kumar C

    Hello Rajesh,
    The "problem" is the logically grouped set of the exception events which have the identical hash calculated over several fields as "Stack", "Source", "Failed Function" and so on... So, even if exceptions are different
    in the other properties but hash matches over the considered properties - then all those exceptions go into the same "problem group".
    So, event is an instance of the problem. One event contributes to one problem but one problem might have a huge event count if you have a repeating issue.
    The logic is similar for the performance analysis report, only fields that go into the "problem" hash are different. e.g. "Stack" is not used in hash for perf events...
    Dmitry Matveev

  • Problem Posting an Event to the EventQueue

    Hi all,
    while i develop a java application i get problem posting ana event to the EventQueue using postEvent method.Here is the problem.i have a menu which have 3 menu items (Load, store, hide).i want when the user click "hide" the code in "store" option excuted plus extra code in option "hide".i tried to implement this using the postEvent of EventQueue. i simlate this by tring to post ActionEvent to simulate user cliks option "store" but this didn't work. can anyone tell me what's the problem.thanks

    try JMenuItem's doClick(). that simulates the user clicking on your menu item.
    thomas

  • Another instance of severe new problem in iCal - events duplicated infinite

    This is like other posted problems. I just went Leopard - Snow Leopard. Have used iCal for years and consider myself experienced. On my first attempt to add a repeating event following the OS upgrade, the repeating event was duplicated hundreds perhaps thousands of times before I even completed the entry in the popup dialog. As you all know, that dialog does not allow cancel or delete. The event is duplicated multiple times in the same day. It seems to have no termination date. It cannot be selected in order to delete it. The color is even a pastel shade of the group color that it was supposed to have.
    I have turned off iSync and hope that I can remove theses ridiculous events before they spread to every Mac and Ipod.
    I cannot find a database to delete or I'd delete it and try to resync from me.com.
    Help, Apple -- we need your attention on this one. It is definitely a **** up in iCal.

    O.k. - I am not experienced in spite of many years of using this turkey. First of, the sync/don't sync button in preferences - forget it. iCal syncs with MobileMe no matter what the setting. Bummer - except that once the hundreds of duplicate, repeat events are transfered to MobileMe, you can delete them from the web interface - unlike the iCal application that forbids deleting unwanted events.
    Second new discovery. You can put in a repeated event on the MobileMe website with no trouble but, bummer again, the new event on MobileMe does not sync back to the iCal on the iMac.
    Final and most important discovery. I got the problem in the first place by blindly supplying the information asked for and, I kid you not, iCal 4 asks for the end date of a repeated event twice. If you answer the question twice, as I did, you get N * N events. So I hope I can avoid the problem in the future. But really, iCal needs methods to delete repeated events. Also as a former long-term Palm user, I sorely miss the option to restore a calendar from another machine. (the ability to sync or overwrite the local application).

Maybe you are looking for