Reusing TransformerHandler

Hi!
I've been taking a look at the JAXP, Xalan etc. and have written a sample application to mirror work that was previously done using command line XSLT processors and XML tools.
The basic idea is a common one - to build a configurable chain of document processing steps including XSLT transformations.
However, I've run into a problem regarding the resuse of Transformers. Currently, the test application creates a vector containing a number of steps. These range from input steps (using org.xml.sax.XMLReader) to output steps (using org.apache.xml.sax.Serializer.)
Each transformation step is a TransformerHandler which is linked to the next step using setResult. Pretty much the same as Pipe.java from the Xalan samples.
Everything is fine for the first document to pass through the chain, however, trying to pass another document through the chain results in the following exception:
java.lang.RuntimeException: java.lang.NullPointerException
     at org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3407)
     at org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
     at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
     at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
     at org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(Unknown Source)
     at org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
     at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
     at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
     at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
     at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
     at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
     at com.mytest.ResourceProcessor.Input.readAndTransform(Input.java:64)
     at com.mytest.ResourceProcessor.Target.build(Target.java:111)
     at com.mytest.ResourceProcessor.ResourceProcessor.buildTargets(ResourceProcessor.java:110)
     at com.mytest.ResourceProcessor.TestApp.main(TestApp.java:24)
Now, this is probably a simple error due to my misunderstanding of the APIs (be kind - I'm new to this!)
What exactly are the rules for reuse of a TransformerHandler?
Thanks in advance for any help.

Reuse of Transformer (your question near the beginning) or reuse of TransformerHandler (your question near the end)?
I don't see any point in reusing a TransformerHandler, since it costs essentially nothing to create a new one. So don't bother. Reusing a Transformer is more conceivable, since creating one requires parsing the XSL it uses. But the rules for reusing them are clearly stated in the API documentation:
"An object of this class may not be used in multiple threads running concurrently. Different Transformers may be used concurrently by different threads.
A Transformer may be used multiple times. Parameters and output properties are preserved across transformations."
If there is a chance of multi-threading (for example if your code is in a servlet environment or similar) then a Templates object is both reusable and thread-safe.

Similar Messages

  • Reusing Time Machine from an external hard drive

    Since now I've read a lot of discussion to solve this issue but I cannot understand how to proceed.
    My situation is the following. I've replaced my old HDD with a SSD. I performed a clean install of ML 10.8.3 without the support of Migration Assistant. Now, I would like to reuse my extarnal drive without erasing my old backups. In other words, I would like to inherit those backups and continue to use my exteranl drive.
    I've found a very good guide for this. In particular, I've read these two FAQs:
    http://pondini.org/TM/B5.html
    http://pondini.org/TM/B6.html
    They are mutual exclusive, I think. If the first one works, you are ok. On the contrary you can follow the second one.
    I have two questions about those FAQs.
    Concerning the first (B5), when will the popup appear?
    Based on my situation, if the popup won't appear, what type of box (B6) do I have to follow? I suppose the pink one but I'm not so sure.
    Thank you in advance.

    Time machine works great for the file you accidentally delete or modify even if you need to go back months and months.  There are better solutions when you really just need to clone your existing system like CCC or Superduper.  A clone is more flexible when it comes to getting your stuff.  The only downside is you will lose the multiple copies time machine keeps.  The upside is you know exactly what's on it and you can boot from it if needed.  The file structure is definately more stable on a clone.
    A time machine is OK for what you're doing.  I just think a clone is better.  The choice is yours.

  • Proving prepared statements are being reused

    How can I prove that a prepared statement from a JDBC driver is being reused / pooled ?
    What essentially I want to do is to have prepared statements reused to reduce hard parsing ... but I also need to prove that the statements are being reused. If I query the statement in V$SQLAREA, the column PARSE_CALLS does not seem to be distinguish between hard parse and soft parse:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96536/ch3204.htm#1126299
    I am only interested for now in proving the just ONE statement is being reused ... which mean that the number of hard parses is very low compared to the number of soft parses for that ONE statement.
    Regards,
    jms
    Message was edited by:
    jms

    Hi,
    No, parse calls is all soft and hard parse together. What you would see, if used absolutely correctly, would be 1 hard parse per session and many executions.
    But since v$sql is obviously not linked to v$session other than at the time of exection, you see the aggregated parse calls and executions for each cursor. So what you should see is parse calls go up relatively slowly to the number of exections.
    However, you can see soft and hard parses using the v$sesstat and v$statname views so you can see soft and hard parses on a session by session basis, be these are again aggregated, so you can't see soft / hard counts per cursor, only the total for a session.
    What I see a lot of the time is they don't get it quite right, so hard parses is low but soft parses are high, so they are still parsing when they don't need to, but at least they are binding and using shareable SQL, which is a step in the right direction.
    When I say 'they', it is a generic reference to all Java/.Nyet programmers writing front end code where they just don't 'get' parsing and binding because it's just too complicated and hey, SQL Server isn't like this...!
    HTH
    Chris

  • PL/SQL reuse in ADF

    Is disabling the use of application module pooling good practice for intranet applications where the number of users are known in advance (although in the thousands)? This was suggested as a solution to limit the amount of recoding that will be required of existing PL/SQL programs that make extensive use of global temp tables/package variables/etc. By disabling pooling (and a few other tweaks) the user will access the db with the same session and hence database state is preserved between requests. But in my experience a lot of PLSQL code is written to fit specific use cases (mostly on Forms) without considering the need to reuse the code in any other context (although I must admit that it can easily happen in any other language). I have repeatedly tried to explain that state is better maintained and much easier to deal with if it sits on the application but perhaps I'm wrong. Any advice will be much appreciated.

    Hi,
    its not enough. If you want to build an ADF application that behaves like Forms, then you need to look for implementing dynamic JDBC credentials so that users have dedicated database connections (which is what Forms is doing). Note that using Application Module pooling and database connection pooling is guaranteeing you better performance so that the question is what the required changes are (global PLSQL variables need to be removed for sure) to PL/SQL so the logic can be used in ADF applications that follow best practices (which is that they run as true Java EE web applications)
    Frank

  • How to reuse a 9iAS Portal database connection in a BC4J application?

    Hi,
    I have a 9iAS Portal 9.0.2 application, and I want to call a BC4J/UIX application from the Portal application. Ideally I would like to reuse the database connection already established within Portal, because it has authenticated the user with the SSO, and has all of the Portal and VPD settings already in the environment. I don't want to ask the users to re-log in.
    I have looked at the Portal Java PDK and cannot find anything appropriate - has anyone accomplished this, or is there another way of doing this?
    Thanks,
    Steve

    BC4J supports JAAS authentication.. look at the jazn stuff. When u deploy your application on 9ias one of the pages in the wizard asks what kind of authenticatoin you would like to use, you might be able to set something up there...
    Also you an secure the URL in the httpd.conf file so that if a user directly attemps to access that application they are presented with the SSO log in screen.

  • ALV Report row grey-out (disable) dynamically -- REUSE ALV!!!

    Hello All,
    Well again a quick question...
    Am using REUSE ALV method to display the ALV report.
    Dynamically by selecting a row in the list (using the checkbox) and by pressing a button on application tool bar, the selected row should be greyed-out(disabled), that is it should not be anymore editable!
    How is it possible?
    Any kind of inputs regarding this will be damn damn helpful.
    Thanks in advance!
    Cheers, Sundar.

    Hi,
    The above solution 1 will be only applicable if using OO ALV!
    above solution 2 will disable the entire column, and then again i need to call the "REUSE ALV"... which i don't want to.. as it opens another screen above the same screen and i have to close it twice!
    I know it is possible to grey out the selected row using OO ALV... i want to know if it is possible in REUSE ALV???
    Keep shooting please....
    Thanks!
    Regards,
    Sundar

  • How to open a URL without session ID and reuse the current browser session?

    Hi All,
    I have a question about HTMLDB 2.0
    How to open a URL without session ID and reuse the current browser session?
    That was the behaviour in HTMLDB 1.6 ...
    My usecase for this is the following:
    We have written an issue tracking application, which sends e-mail to the interested users, when something happens.
    In these email we've put a link to some page, with some parameters in the URL.
    The idea is for the user to be easy to click on the hyperlink and to see the details of the ticket.
    When the user clicks on such a link he is directed to a login screen (page 101) and he enters his Username and password, and is then forwarded to the details for the ticket.
    Then he receives another email (e.g. for another ticked). He clicks on the link and :
    a) in HTMLDB 1.6 he goes to the details as he didn't close his browser and session is remembered
    b) in HTMLDB 2.0 he is prompted to enter username, password with the username populated
    Please tell me how can I achieve the same behaviour in HTMLDB2.0 as it was in HTMLDB 1.6.
    I understand this change is somehow security related, althogh I don't understand how. If you can explain this either I would be very happy?
    Best regards,
    Mihail Daskalov

    Mihail - I detailed a couple of approaches here: Re: Application Link
    Scott

  • How to reuse standard Activity subcomponents - Appointments, Tasks, Phone Calls and Emails within a custom work center?

    Requirement : We have a requirement to reuse the standard Activity subcomponents Appointments, Tasks, Phone Calls and Emails within a custom work centre. The requirement is to leverage and copy all sub functionalities Appointments, Tasks, Phone Calls and Emails available within the standard activity work center. This feature is available within Accounts, Opportunities, Leads etc. (Refer screenshot: Std_Act_Screen.jpg)
    We are unable to consume/embed the standard Activity (Work center) sub components Appointments, Tasks, Phone Calls and Emails within the custom work center. This is because of backend consistency check violation UI designer error message displayed. (Refer screenshot:Error while consuming standard activities.jpg)
    Ø  Open Question:
    a.      Is there a limitation to consume/embed the standard Activity (Work center) subcomponents Appointments, Tasks, Phone Calls and Emails within a custom work center?  We have noticed that this standard Activity Work center subcomponents Appointments, Tasks, Phone Calls and Emails has been repeatedly reused within the application in Account, Opportunity, Sales lead, Lead, Sales Quote Objects.
    b.      Is there an alternative way in which we can call [Through API etc..] the standard Activity Work center subcomponents Appointments, Tasks, Phone Calls and Emails?
    We need your guidance to overcome the error to enable the reuse of the standard Activity Work center sub-components Appointments, Tasks, Phone Calls and Emails within our custom work center or suggest a suitable workaround on how this can be achieved.
    Regards .. Dheeraj Saini

    Whenever you find out let me know. I wanted to assign a text tone to someone and now in iOS 7 i can't. Or I haven't figured this out yet.

  • Server 2012 R2 RDS Personal Collection -reuse VM names after a partial job failure

    I am currently testing RDS on server 2012 R2, and as part of the test I have built and rebuilt multiple collections of VMs. I have noticed that when creating a new JOB to build a personal collection, sometimes I get VM build failures on one host. The build
    failures are usually due to a networking issue, which I then resolve, but when I go to add/create the VMs that failed, the name of the VMs increment from the last VM, and they don't re-use the failed names. I want to be able to reuse/build the VMs that
    failed.
    eg.
    VM-01, VM-02, VM-03 - On HOST-01 all work
    VM-04, VM-05, VM-06 - On HOST-02 fail
    VM-07, VM-08, VM-09 - On HOST-03 all work
    So on this example, when I re-run the job to build the missing/failed VMs, it would build  VM-10, VM-11, VM-12 on HOST-02.
    Is there a way to reset, or reuse the failed VM names, in the example above that would be VM-04, VM-05, and VM-06?
    Thanks

    Hi,
    Thank you for posting in Windows Server Forum.
    For a try you can use powershell command for RD VDI infrastructure.
    New-RDVirtualDesktopCollection -CollectionName "ITCamp" -PooledManaged -StorageType CentralSmbShareStorage -VirtualDesktopAllocation 5 -VirtualDesktopTemplateHostServer $VHost -VirtualDesktopTemplateName $VDITemplateVM -ConnectionBroker $RDBroker -Domain “contoso.com”
    -Force -MaxUserProfileDiskSizeGB 40 -CentralStoragePath”\\fileserver1\NormalVMs” -VirtualDesktopNamePrefix "ITC" -OU “VDICampUsers” -UserProfileDiskPath \\fileserver1\NormalProfiles
    More information.
    Lab Ops 7 – Setting up a pooled VDI collection in Windows Server 2012 R2
    http://blogs.technet.com/b/andrew/archive/2013/10/28/lab-ops-4-windows-8-1-windows-2012r2-vdi.aspx
    Also check that when setting up RDS, there needs to be a Physical NIC with IP for the creation of a RDS vSwitch. If this vswitch does not exist, the creation of the MV's will fail.
    Hope it helps!
    Thanks.
    Dharmesh Solanki

  • How do I reuse a custom java control in another project?

    Relatively simple question, but I am having a lot of trouble with this. Documentation
    alludes to this being possible and easy, but never says how (and the only tutorials
    I can find describe creating a custom java control in the same project where they
    are used):
    "You can design a custom control for use in one project, or you can design a custom
    control for easy reuse in multiple projects." (from WLS docs on Java Controls)
    "When the control project builds, all of the controls and associated files are
    compiled into a single jar file and pushed onto the classpath of the containing
    application for immediate use and testing by other projects in the application.
    This jar is self-contained and can be moved to any other application by adding
    it to the application’s Library folder. Appropriately marked controls in the Library
    it will automatically appear on the user’s palette, ready for incorporation into
    an application." (from dev2dev article on controls, P. Hussey)
    I have a Workshop application which contains a few projects. One project is a
    component project, another is a web project. I created a custom java control in
    the control project and built it (JAR appeared in the Libraries folder). Now I
    open up the page flow in my web app project, and try to drag the java control
    onto my page flow - but I get an eror that the control must reside in the same
    project! It does not automatically appear on my palate, so if I go over to the
    palate on the right, and try to "add control" I only get a list containing the
    BEA controls - no custom controls are listed.
    What am I doing wrong? How can I incorporate my custom control into a web project?
    I don't want to move the control in the web project, since this contradicts the
    concept of a separate shared library. I should be able to build a library of controls
    and reuse them in our web projects right?
    -Bob

    Please disregard... I got it to work. For some reason I had to close Workshop,
    restart it, then I reloaded the application, rebuilt the control project, and
    now my control appears in the list of controls and can be easliy added to the
    palette.
    "Bob" <[email protected]> wrote:
    >
    Relatively simple question, but I am having a lot of trouble with this.
    Documentation
    alludes to this being possible and easy, but never says how (and the
    only tutorials
    I can find describe creating a custom java control in the same project
    where they
    are used):
    "You can design a custom control for use in one project, or you can design
    a custom
    control for easy reuse in multiple projects." (from WLS docs on Java
    Controls)
    "When the control project builds, all of the controls and associated
    files are
    compiled into a single jar file and pushed onto the classpath of the
    containing
    application for immediate use and testing by other projects in the application.
    This jar is self-contained and can be moved to any other application
    by adding
    it to the application’s Library folder. Appropriately marked controls
    in the Library
    it will automatically appear on the user’s palette, ready for incorporation
    into
    an application." (from dev2dev article on controls, P. Hussey)
    I have a Workshop application which contains a few projects. One project
    is a
    component project, another is a web project. I created a custom java
    control in
    the control project and built it (JAR appeared in the Libraries folder).
    Now I
    open up the page flow in my web app project, and try to drag the java
    control
    onto my page flow - but I get an eror that the control must reside in
    the same
    project! It does not automatically appear on my palate, so if I go over
    to the
    palate on the right, and try to "add control" I only get a list containing
    the
    BEA controls - no custom controls are listed.
    What am I doing wrong? How can I incorporate my custom control into a
    web project?
    I don't want to move the control in the web project, since this contradicts
    the
    concept of a separate shared library. I should be able to build a library
    of controls
    and reuse them in our web projects right?
    -Bob

  • How do I force Safari history to open in new tab instead of reusing current

    By default, Safari reuses the current tab when opening the history results, which forces a reload of that page when history is closed. Is there a way to force history to open in a new tab of its own?

    Is there any way to make this the default behavior without relying on a modifier key?

  • How can i reuse my existing socket connection

    Hi,
    this might sound basic, it probably is:
    As part of my larger project, i have to send and recieve data to multiple socket connections.
    The thing that happens is that everytime i send data, it seems that java is creating a new stream or something (code is multithreaded)
    so as i send 4 items of data, a bit like a chat program sending 4 statements, it creates 4 different streams, instead of using the same stream. therefore when i close the connection, i get:
    java.net.SocketException: Connection reset 4 times.
    i know why.. its because i have added the:
    Socket socket=new Socket(host, port);
    BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()));
    bit in the same method with the
    out.println(THE DATA....);
    out.flush();
    The thing what i want to do is to create the connection one, and reuse the objects:
    out, in and socket
    to send / recieve the new data.
    please help me guys,
    thanks

    All the threads would be able to get the same reference to....
    class SocketWrapper {
         private final Object readLock = new Object();
         private final Object writeLock = new Object();
         // client side
        public SocketWrapper(String hostname, int port);
         // server side.
        public SocketWrapper(Socket);
         // send data
         public void send(Serializable object) throws IOException;
         // receive data. synchronized(writeLock);
         public Serializable getNext() throws IOException;
         // create a new socket as required, throw IllegalState if server side. synchronized(readLock)
         private void createNewSocket() throws IllegalStateException;
    }The send autoconnects as required. It then send on message/packet/object.
    The getNext autoconnects as required. It reads one message/packet/object and returns.
    This allows multiple threads to access the same socket. It allows data to be sent while a thread is blocking on a read. (Thus two locks)

  • Is there a way to create standard text messages that can be reused easily

    is there a way to create standard text messages that can be reused easily

    if you meant phrases, then Yes
    Setteings> general>keyboard> add new shortcut

  • Is it possible to reuse the Scanner instance in this case?

    I have a data file that gets updated by another process, and in my program I periodically read the file, and if there'S new data added I will update my data structure (contained in ArrayLists).
    The issue is for every read I have to re-create a Scanner instance and skips all the lines that have been read. Since the file could get really long, and to skip lines in the file we need still to call scanner.readLine() which might be expensive since it interacts with the hard disk, I'm trying to reuse the Scanner instance and count on the scanner.hasNextLine() to return true if new lines are inserted to the file by the other process:
    while (in.hasNextLine()) {
    String line = in.nextLine();
    // intepret th eline here
    This code is put in a Runnable that is executed periodically, and I was hoping that the next time it is called in.hasNextLine() would return true and we can happily start where we were left off.
    But the bloody method does NOT return true even though new lines have been added to the file. Does anyone know to make it recognize that the file has been updated? Or really there's no other way but to re-open the file and skip old lines as I'm doing now?
    Any suggestion would be highly appreciated!
    P.S: How could I add code tags to highlight my code portion? Thanks!

    808239 wrote:
    I have a data file that gets updated by another process, and in my program I periodically read the file, and if there'S new data added I will update my data structure (contained in ArrayLists).Is there any reason you can't use a Stream instead of a file? Unix has a nice little utility called 'tee' that allows you to write out to a file AND stdout, allowing you to connect other commands via a pipe. I'm sure you could write something similar for Java; however, if this is intended as a daemon process, you'd probably have to make it non-blocking, which might be an issue.
    Alternatively, have you considered using a database instead of a file?
    Winston

  • Unable to reuse a port for UDP on Windows

    I have a UDP server running on a specific port. When I create the socket on this port, I first created it unbound, set the reuseaddr option to true and then bound it to this port. When I receive a new connection to this port, I spawn a new thread and this new thread creates a new socket on the same port using the same method describes earlier. The new thread then does a connect to this new client.
    The problem is that after the connect, the main thread is not able to receive anything on the port. The new thread is fine and handles all the traffic coming from it's connected client. The main thread is pretty useless. Only after the new thread is done and it closes the socket, the main thread starts receiving stuff again.
    The most interesting thing out of all this is that this behaviour is seen only only Windows. My code works fine on Linux. The main thread accepts new connections and spawns new threads which do connects and so on.
    I am stumped. How do I make windows do multithreading on a UDP socket reusing the same port?

    Cross/multi-posted, so don't answer here, ok?
    http://forum.java.sun.com/thread.jsp?thread=452580&forum=31&message=2059046

Maybe you are looking for

  • Writing Academy Leader

    Hello, all. I'm getting ready to score my feature in Logic. I want to have a QT video with the movie's first frame (beginning titles and music) timecode at 01:00:00:00. This will only be a video export. No audio, as I am planning on OMFing my audio i

  • SSL Problem again!!!

    A month or so ago I finally got ssl to work on our first master. I had to use a Entrust certificate because our verisighn one was not working. Now I'm going through the same stuff w/ the second master. Has anyone had these kind of problems. The wierd

  • 11g Grid Control in a cluster?

    Hi All, I am trying to find some official doc on how to setup an MAA architecture for 11g GC. I have already done the following: - installed 11.2.0.1 RAC database - installed wls 10.3.2 on both nodes - installed OMS on one node - added the second OMS

  • AS2 call javascript function of another webpage. help :)

    Hi I have an swf in as2 and when I click a button, I want to open a new html page, and in that page I have a function that depend of the value, i show or hide one table the question is, how can I open that page and send that value, and in that page s

  • What ID does password recovery procedure work on?

    We recently completed the steps to recover password on a 2960G switch as per instructions found at http://www.cisco.com/en/US/products/hw/switches/ps628/products_password_recovery09186a0080094184.shtml  Four password were changed as per documentation