XSLT with DOMSource

I'm trying to do an XSLT transformation with DOMSource as follows:
javax.xml.transform.Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new FileWriter(new File(FileName)));
transformer.transform(source, result);
transformer = tFactory.newTransformer(new StreamSource(new StringReader(XSLT))); // XSLT is XSLT String.
//transformer.transform(new StreamSource(FileName), new StreamResult(new FileOutputStream("C:\\tmp\\2692xslt.xml"))); // Works fine.
transformer.transform(source, new StreamResult(new FileOutputStream("C:\\tmp\\2692xslt.xml"))); // Doesn't work fine.
The last line doesn't produce intented output. But if we read from file, as in last-but-one line, it works fine. Is there something wrong in directly converting from source?
Thanks,
Viikas

The last line doesn't produce intented output. But if we read from file, as in last-but-one line, it works fine. I sense some deliberation of being cryptic, "intended output".
Is there something wrong in directly converting from source?There should not be.
But the problem can be looked from this angle: namely, the last line is done without the intervention of an intermediate step of passing through an identity transformation and reloading whereas the last-but-one line does.
You can do this so that you can check the output now coincide with the "intended output" or not.
//start from your first two lines
javax.xml.transform.Transformer transformer = tFactory.newTransformer();
DOMSource source=new DOMSource(doc);
DOMResult domresult=new DOMResult();
Document doc2=null;
DOMSource source2=null
transformer.transform(source, domresult);
doc2=(Document)domresult.getNode();
source2=new DOMSource(doc2);
//your line
transformer = tFactory.newTransformer(new StreamSource(new StringReader(XSLT))); // XSLT is XSLT String.
// Does it work fine (according to your sense) now?
//This should produce the same output as your last-but-one line being your "intended output" without passing through saving and reloading physical file and all done in memory.
transformer.transform(source2, new StreamResult(new FileOutputStream("C:\\tmp2692xslt.xml")));Edited by: tsuji on Feb 29, 2012 7:19 AM
Edited by: tsuji on Feb 29, 2012 10:03 PM (edited another typos on naming of variable result/domresult, sorry!)

Similar Messages

  • XSLT fails with DOMSource succeeds with StreamSource

    I'm trying to use XSLT to convert one XML document to another XML format. My stylesheet works when I use StreamSource for the source XML, but if I use DOMSource it doesn't convert it over instead the resulted XML is the following:
    <?xml version="1.0" encoding="UTF-8"?>\n\r\n\r\n\r \n\r\n\r
    StreamSource for the XML document works perfectly, and gives me the transformed document. Here is the code I'm using to convert the XML document using XSL.
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse( policyFile );
            Element root = doc.getDocumentElement();
            String namespace = root.getAttribute("xmlns");
            String schemaVersion = root.getAttribute("schema-version");
            int index = schemaVersion.lastIndexOf(".");
            if( index > 0 ) {
                schemaVersion = schemaVersion.substring( 0, index );
            return convertSource( new DOMSource( doc ), new StreamSource(getConversionFile( namespace, schemaVersion )) );If I change the last time to :
            return convertSource( new StreamSource( policyFile ), new StreamSource(getConversionFile( namespace, schemaVersion )) );It produces the right output. Why is this not working with DOMSource?
    Charlie

    Here is the definition of convertSource():
    private String convertSource( Source source, Source styleSheet ) throws TransformerException {
    StringWriter writer = new StringWriter();
    getTransformer(styleSheet).transform( source, new StreamResult( writer ) );
    return writer.toString();

  • XSLT with RTF

    Anyone written out a table of contents before with XSLT & xml.
    I have a document with many sections, want a TOC entry for each section
    for some reason this code does not work properly no output. But if i take away the tc & tcn tags it prints out the value. Please help
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="/">
    <xsl:text>{\rtf1</xsl:text>
    <xsl:text>{\tc-</xsl:text>
    <xsl:for-each select="Proposal/Section">     
    <xsl:text>{\tcn-</xsl:text>
              <xsl:value-of select="Name"/>
    <xsl:text>}</xsl:text>          
    </xsl:for-each>
    <xsl:text>}</xsl:text>
    <xsl:text>}</xsl:text>
    </xsl:template>
    </xsl:stylesheet>

    The last line doesn't produce intented output. But if we read from file, as in last-but-one line, it works fine. I sense some deliberation of being cryptic, "intended output".
    Is there something wrong in directly converting from source?There should not be.
    But the problem can be looked from this angle: namely, the last line is done without the intervention of an intermediate step of passing through an identity transformation and reloading whereas the last-but-one line does.
    You can do this so that you can check the output now coincide with the "intended output" or not.
    //start from your first two lines
    javax.xml.transform.Transformer transformer = tFactory.newTransformer();
    DOMSource source=new DOMSource(doc);
    DOMResult domresult=new DOMResult();
    Document doc2=null;
    DOMSource source2=null
    transformer.transform(source, domresult);
    doc2=(Document)domresult.getNode();
    source2=new DOMSource(doc2);
    //your line
    transformer = tFactory.newTransformer(new StreamSource(new StringReader(XSLT))); // XSLT is XSLT String.
    // Does it work fine (according to your sense) now?
    //This should produce the same output as your last-but-one line being your "intended output" without passing through saving and reloading physical file and all done in memory.
    transformer.transform(source2, new StreamResult(new FileOutputStream("C:\\tmp2692xslt.xml")));Edited by: tsuji on Feb 29, 2012 7:19 AM
    Edited by: tsuji on Feb 29, 2012 10:03 PM (edited another typos on naming of variable result/domresult, sorry!)

  • Open XML and using xslt with JavaScript

    Hello,
    I want the user to be able to choose an XML-file. This XML-file should not be placed in InDesign, there is not even a document needed for my script. All I need is a variable, containing the file. However, the XML-file should be transformed with xslt into another XML-file. How do I do this?
    This is how I open the first XML-file, the one that should be transformed:
       var xmlDoc = File.openDialog ("Choose XML");
       if (xmlDoc == null) {return;}
        xmlDoc.open("r");
        xmlDoc = xmlDoc.read();
        xmlDoc = new XML(xmlDoc);
    I can adress different nodes and use xmlDoc as an XML-file, so that's fine, but how do I transform it?
    I read the Scripting Guide and tried this:
        var myDocument = app.documents.add();
        var myXMLImportPreferences = app.xmlImportPreferences;
        myXMLImportPreferences.transformFilename = "c:\myTransform.xsl";
        var xx = myDocument.importXML(File.openDialog ("XML"));
    However, it's not exactly what I want since I have to create a document and it's not working either, since xx stays undefined.
    Thanks for your help.

    You can't get exactly what you want.
    Your first code example uses the InDesign JavaScript interpreter's XML support, called E4X. It has absolutely nothing to do with the InDesign document object model or InDesign's internal support for XML. It exists only within the JavaScript interpreter. It does not support XSLT transformations.
    Your second example leverages InDesign's built-in XSLT support (I'm not too sure how this works...); but that is only useful when importing XML into
    InDesign, which, as you have learned, requires a document.
    In the first example, you could call out to an external invokation of xsltproc and read in the input. How to do that differs for Windows and Mac.
    In the second example, you could export the XML from your Document back out to an XML file and read it back in with E4X.
    None of this is very appealing. What do you really need to do?

  • How can I export a stylesheet (either CSS or XSLT) with XML from indesign?

    Hi,
    I am using indesign CS4. I want to export style sheet whether it is CSS or XSLT file with xml.
    I try to get it but can't.
    Also the XML i am exporting does not styles that has been applied by me while creating the file in Indesign.
    Please help me out by telling me the way how can i get a stylesheet and also how can I embed that style sheet with XML so that my XML file looks similiar to the indesign file.
    Thanks,
    Choudhary Nafees Ahmed

    I am using indesign CS4. I want to export style sheet whether it is CSS or XSLT file with xml.
    CSS is not an XML style sheet, it's an HTML style sheet. "Export to HTML" will export an empty stylesheet for the paragraph and character styles. ID cannot convert its (very advanced) typographic capabilities to the (very limited) CSS notation, and thus it defaults to exporting the names only.
    XSLT is not an XML style sheet either; it's a transformation format (http://www.w3.org/TR/xslt).
    I try to get it but can't.
    Also the XML i am exporting does not styles that has been applied by me while creating the file in Indesign.
    XML Export does not export anything except the items you tagged with the Auto-tag feature, or you tagged yourself. If you need your styles tagged, use Map Styles to Tags (http://www.adobe.com/accessibility/products/indesign/mapping.html).
    XML has almost nothing to do with styling -- ideally, XML describes document structure while styles describe formatting.

  • Transformation to WORD from XSLT with java stored procedure - PROBLEM

    Hi all,
    I'm building a java function for transformation of xml document through .xslt scheme to WORD. I use xalan.
    Now, everything works fine if I run the java function on the client VM
    But on the server where the classes needed for the transformation are loaded, it crashes with a strange exception
    nulljava.lang.NullPointerException
    Now I've located the problem, and it occurs in this line in the java code:
    transformer.transform( new StreamSource(xmlFile),  new StreamResult(osIzlez));
    (where xmlFile is the source for the transformation, and the transformer is configured with the proper .xslt scheme, osIzlez points to a bytearraystream of a blob in the database where the .doc file is going to be generated and loaded)
    I also found out that the NullPointerException occurs because the transformer is actually null on the server (although it's configured with the .xstl scheme and should not be null ! ), but on the client it's never null!
    What could be the problem, does anyone have an IDEA?
    Edited by: Daniel Kiprijanovski on 17.9.2009 03:07

    OK, i found out that there's a reported bug about that exception on the java VM. I found a way arround it however.
    Thanks,
    Daniel K.

  • Lookup in Xi using XSLT with Java enhancement "Error"

    Hi Experts,
    I need your advice urgently.
    I have done message mapping using XSLT mapping with Java enhancement.
    I included the code for SAP DB connection to read from the table.
    I imported both the sapdbc-7_6_00_30_5567 Driver.jar and my custom jar into imported archives.
    I used the java functions in my XSLT to get the lookup value.
    The code was working correctly in NWDS, but when i tried to execute the scenario, it gave me 'SYSTEM ERROR'
    Following is the error as seen in SXMB_MONI
      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
    - <!--  Request Message Mapping
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
      <SAP:Category>Application</SAP:Category>
      <SAP:Code area="MAPPING">TRANSFORMER_EXCEPTION</SAP:Code>
      <SAP:P1>PortalTransaction_EP_to_Insert_EP_DB</SAP:P1>
      <SAP:P2>http://ab.com/xys/subscription</SAP:P2>
      <SAP:P3>8abf9c80-ad4a-11db-bb9a-ccaaac110865</SAP:P3>
      <SAP:P4>-1</SAP:P4>
      <SAP:AdditionalText />
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack>Exception occurred during XSLT mapping of the application</SAP:Stack>
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    Following is the DEBUG trace when i tries to test the Interface Mapping
    Creating mapping sequence with 2 steps.
    Creating step 0
    Creating XSLT mapping PortalTransaction_SUBSYS_to_PortalTransaction_EP
    Creating step 1
    Creating XSLT mapping PortalTransaction_EP_to_Insert_EP_DB
    Start executing mapping sequence with 2 steps.
    Executing mapping step 0
    Call XSLT processor with stylsheet PortalTransaction_SUBSYS_to_PortalTransaction_EP.xsl.
    Returned form XSLT processor.
    XSLT transformation: PortalTransaction_SUBSYS_to_PortalTransaction_EP.xsl completed with 0 warning(s).
    Mapping step 0 has been executed.
    Executing mapping step 1
    Call XSLT processor with stylsheet PortalTransaction_EP_to_Insert_EP_DB.xsl.
    Loaded class com.cityandguilds.clasp.xi.DateTimeFunctions
    Method fatalError called, terminate transformation
    javax.xml.transform.TransformerException: com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:251) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:65) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) ... 19 more Caused by: java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) ... 34 more -
    com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) -
    at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:65) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) ... 34 more
    TransfromerException during XSLT processing:
    javax.xml.transform.TransformerException: com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:251) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:65) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) ... 19 more Caused by: java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) ... 34 more -
    com.sap.engine.lib.xml.util.NestedException: java.lang.ClassNotFoundException: Class doesn't have appropriate method! -> java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) -
    at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:65) at com.sap.engine.lib.xsl.xpath.JLBLibrary.getFunction(JLBLibrary.java:107) at com.sap.engine.lib.xsl.xpath.LibraryManager.getFunction(LibraryManager.java:76) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:98) at com.sap.engine.lib.xsl.xpath.ETFunction.evaluate(ETFunction.java:83) at com.sap.engine.lib.xsl.xpath.XPathProcessor.innerProcess(XPathProcessor.java:56) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:43) at com.sap.engine.lib.xsl.xpath.XPathProcessor.process(XPathProcessor.java:51) at com.sap.engine.lib.xsl.xslt.XSLVariable.process(XSLVariable.java:132) at com.sap.engine.lib.xsl.xslt.XSLNode.processFromFirst(XSLNode.java:296) at com.sap.engine.lib.xsl.xslt.XSLTemplate.process(XSLTemplate.java:272) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:463) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:431) at com.sap.engine.lib.xsl.xslt.XSLStylesheet.process(XSLStylesheet.java:394) at com.sap.engine.lib.jaxp.TransformerImpl.transformWithStylesheet(TransformerImpl.java:398) at com.sap.engine.lib.jaxp.TransformerImpl.transform(TransformerImpl.java:240) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingTransformer.transform(RepMappingTransformer.java:150) at com.sap.aii.ibrep.server.mapping.ibrun.RepXSLTMapping.execute(RepXSLTMapping.java:81) at com.sap.aii.ibrep.server.mapping.ibrun.RepSequenceMapping.execute(RepSequenceMapping.java:54) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0.transform(MapServiceRemoteObjectImpl0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0p4_Skel.dispatch(MapServiceRemoteObjectImpl0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170) Caused by: java.lang.ClassNotFoundException: Class doesn't have appropriate method! at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.init(JLBFunction.java:273) at com.sap.engine.lib.xsl.xpath.functions.JLBFunction.<init>(JLBFunction.java:63) ... 34 more
    17:44:11 End of test
    Thanks in advance,
    Mona

    Hi,
    Thanks to all who replied.
    I solved the problem.
    I was calling the java method from XSLT without passing any arguement.
    I realised that the java methods called from XSLT should always have input parameter. So i changed the javamethod call from
    public static String getCurrentRecNo() to public static String getCurrentRecNo(Object test)
    and it worked.
    Can anybody explain me why java methods called from XSLT should always have an input arguement.
    Thanks
    Mona

  • XSLT with large file size

    Hello all,
    I am very new to XSL. I have been reading a lot on it. I have a small transformation program which takes an xml file, an xsl file and performs the transformation. Everything works fine when the file size is in terms of KB. When I tried the same program with the file size of around 118MB, it is giving me out of memory exception. I would appreciate any comments to make my program work for bigger file size. I am posting my java code and xsl file
    public static void xsl(String inFilename, String outFilename, String xslFilename) {
    try {
    // Create transformer factory
    TransformerFactory factory = TransformerFactory.newInstance();
    // Use the factory to create a template containing the xsl file
    Templates template = factory.newTemplates(new StreamSource(
    new FileInputStream(xslFilename)));
    // Use the template to create a transformer
    Transformer xformer = template.newTransformer();
    // Prepare the input and output files
    Source source = new StreamSource(new FileInputStream(inFilename));
    Result result = new StreamResult(new FileOutputStream(outFilename));
    // Apply the xsl file to the source file and write the result to the output file
    xformer.transform(source, result);
    } catch (FileNotFoundException e) {
    System.out.println("Exception " + e);
    } catch (TransformerConfigurationException e) {
    // An error occurred in the XSL file
    System.out.println("Exception " + e);
    } catch (TransformerException e) {
    // An error occurred while applying the XSL file
    // Get location of error in input file
    SourceLocator locator = e.getLocator();
    int col = locator.getColumnNumber();
    int line = locator.getLineNumber();
    String publicId = locator.getPublicId();
    String systemId = locator.getSystemId();
    System.out.println("Exception " + e);
    System.out.println("locator " + locator.toString());
    System.out.println("line : " + line);
    System.out.println("col : " + col);
    System.out.println("No Exception");
    xsl file :
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="/">
    <xsl:element name="Hosts">
    <xsl:apply-templates select="//maps/map/hosts"/>
    </xsl:element>
    </xsl:template>
    <xsl:template match="//maps/map/hosts">
    <xsl:for-each select="*">
    <xsl:element name="host">
    <xsl:element name="ip"><xsl:value-of select="./@ip"/></xsl:element>
    <xsl:element name="known"><xsl:value-of select="./known/@v"/></xsl:element>
    <xsl:element name="targeted"><xsl:value-of select="./targeted/@v"/></xsl:element>
    <xsl:element name="asn"><xsl:value-of select="./asn/@v"/></xsl:element>
    <xsl:element name="reverse_dns"><xsl:value-of select="./reverse_dns/@v"/></xsl:element>
    </xsl:element>
    </xsl:for-each>
    </xsl:template>
    Thanks,
    Namrata
    </xsl:stylesheet>

    One thing you could try to do is avoid using xpath like ".//" and "*".
    I had many problems in terms of memory consuptiom and performance with xpaths like above.
    Altrought you have a little more work to code your xslt it performs better, and probably you will write once and run many times.

  • XSLT with namespaces

    Hello everyone:
    I am using the xalan-j_2_2_D9 from apache to design my style sheets. I was going through the examples that come along with the package and tried out the simple transform program for a style sheet and a corresponding xml file.
    It was strange really, when I apply the stylesheet to an xml file which has no namespaces...it works fine...bbut if there is a namespace there I get nothing.
    Is there any specific approach to be used in xslt if the xml record has namespaces
    Thanks
    Prashanth

    some code to support what I said above.....
    say I have the xml file....
    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="sample1.xsl"?>
    <CATALOG xmlns="http://www.xyz.com/schema" xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance" xmlns:abc="http://www.xyz.com/schema" xsi:schemaLocation="http://www.xyz.com/xsd/metadatav1p1 xyz_rootv1p1.xsd">
         <CD>
              <abc:TITLE>Empire Burlesque</abc:TITLE>
              <ARTIST>Bob Dylan</ARTIST>
              <COUNTRY>USA</COUNTRY>
              <abc:COMPANY>Columbia</abc:COMPANY>
              <PRICE>10.90</PRICE>
              <YEAR>1985</YEAR>
         </CD>
    </CATALOG>
    and my stylesheet reads as follows....
    <?xml version='1.0'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
    <html>
    <body>
    <xsl:for-each select="CATALOG">
    <xsl:value-of select="CD/ARTIST"/>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>
    </xsl:stylesheet>
    I use the XALAN's simpletransform program
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.stream.StreamSource;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerConfigurationException;
    // Imported java classes
    import java.io.FileOutputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    * Use the TraX interface to perform a transformation in the simplest manner possible
    * (3 statements).
    public class SimpleTransform
         public static void main(String[] args)
    throws TransformerException, TransformerConfigurationException,
    FileNotFoundException, IOException
    // Use the static TransformerFactory.newInstance() method to instantiate
    // a TransformerFactory. The javax.xml.transform.TransformerFactory
    // system property setting determines the actual class to instantiate --
    // org.apache.xalan.transformer.TransformerImpl.
         TransformerFactory tFactory = TransformerFactory.newInstance();
         // Use the TransformerFactory to instantiate a Transformer that will work with
         // the stylesheet you specify. This method call also processes the stylesheet
    // into a compiled Templates object.
         Transformer transformer = tFactory.newTransformer(new StreamSource("xmlToHTML.xsl"/*Stylesheet*/));
         // Use the Transformer to apply the associated Templates object to an XML document
         // (foo.xml) and write the output to a file (foo.out).
         transformer.transform(new StreamSource("sample.xml"/*XML File*/), new StreamResult(new FileOutputStream("birds1.htm/*Output File*/")));
         System.out.println("************* The result is in birds1.htm *************");
    CODE COURTESY: Apache
    I get no output in my birds1.htm file except the html and body tags.!
    Can anybody please help me out with this
    Thanks a lot in advance
    Prashanth

  • XSLT with XML XPath references

    I have not used XSLT, and don't need to much, but have questions on creating XML that will be used by client's XSLT.
    We are using a tool (xstream) that automatically transforms a Java object into XML. When it has multiple references to the same object, instead of expanding it in each place, it refers to the previous location of the object. It can do this in two ways (examples below).
    My question is, can XSLT use the XPath or RefID to navigate the XML? I know XSLT uses XPath, but I'm not sure if it uses it in this way.
    -- Note in the following examples how 'type' and 'item' are the exact same object, and the second instance of the object refers to the first location in the XML doc.
    <saleLineItemGrouping>
      <item class="item">
        <id>3000</id>
        <retailPrice>
          <type>
             <code>USD</code>
             <description>US Dollars</description>
             <decimalPlaces>2</decimalPlaces>
             <locale>en_US</locale>
          </type>
          <amount>400000000</amount>
        </retailPrice>
        <markdownAmount>
          <type reference="../../retailPrice/type"/>
          <amount>0</amount>
        </markdownAmount>
      </item>
      <lineItems>
        <saleLineItem>
          <item class="item" reference="../../../item"/>
    <saleLineItemGrouping id="1">
      <item class="item" id="2">
        <id>3000</id>
        <retailPrice id="3">
          <type id="4">
             <code>USD</code>
             <description>US Dollars</description>
             <decimalPlaces>2</decimalPlaces>
             <locale id="5">en_US</locale>
          </type>
          <amount>400000000</amount>
        </retailPrice>
        <markdownAmount id="6">
          <type reference="4"/>
          <amount>0</amount>
        </markdownAmount>
      </item>
      <lineItems id="7">
        <saleLineItem id="8">
          <item class="item" reference="2"/>

    So as I read your answer, I understand XSLT cannot
    "construct XPath expressions." But, can it read in
    XML with that XPath notation?Sure, it can read in that XML. It's well-formed XML so why not? But I gather you want your XSLT to take those attributes, whose values are strings, and interpret those strings as XPath expressions. That, XSLT can't do.
    To put it another way, the XPath expressions in an XSLT stylesheet have to be basically hard-coded there. So you could possibly solve your problem by first transforming the XML into an XSLT containing those expressions; e.g.<type reference="../../retailPrice/type"/>could be transformed into<xsl:value-of select="../../retailPrice/type"/>and then use that XSLT to do the actual transforming. But it would be extremely difficult to make that work -- I wouldn't want to have to do it myself.
    The second idea, using reference="2" to refer to <item class="item" id="2">, is much more feasible.
    Thank you for your replies and your patience.You're welcome. Have fun with XSLT.

  • XSLT with namespaces/schema

    Hi everybody !
    I've a problem transforming a XML file that has a root element containing a reference to a XSD schema.
    <myxml xmlns="http://www.myxml.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.myxml.de myxml.xsd">
    The XSLProcessor does not accept the attribute in the root element but always complains that to be empty :-((.
    I was told, that one of the few processors that could handle Schema and namespaces was the Oracle v2 lib.
    So I'm trying to transform with the following piece of code and ORACLE v2 parser lib:
    import java.io.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    public class SimpleTrAX
    public static void main( String[] args )
    try
    File xslIn = new File( "D:/A.xslt" );
    File xmlIn = new File( "D:/B.xml" );
    File xmlOut = new File( "D:/C.xml" );
    // System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
    // System.setProperty( "javax.xml.parsers.DocumentBuilderFactory", "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl");
    // System.setProperty( "javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl");
    // System.setProperty( "javax.xml.parsers.SAXParserFactory", "org.apache.crimson.jaxp.SAXParserFactoryImpl");
    // System.setProperty( "javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl");
    xmlOut.createNewFile();
    TransformerFactory transFact = TransformerFactory.newInstance();
    StreamSource xslStream = new StreamSource( xslIn );
    StreamSource xmlStream = new StreamSource( xmlIn );
    FileOutputStream fileOut = new FileOutputStream( xmlOut );
    StreamResult xmlResult = new StreamResult( fileOut );
    Transformer trans = transFact.newTransformer( xslStream );
    trans.transform( xmlStream, xmlResult );
    catch (Exception e) { System.out.println( e ); }
    I haven't found any attributes or properties to set the transformer or it's factory to be namespace aware. Any help or helpful hint will be highly appreciated ! Thanks in advance !
    Best regards
    Juergen

    Thanks for your quick answer !
    But including the namespace which is part of the root element in file A into the transforming stylesheet (as you proposed) that should produce result file C seems to
    mislead the transformer:
    It now validates the root tags of the transformation script against the wrong namespace/schema:
    <xsl:stylesheet version="1.0"
    xmlns="http://www.myxml.de"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.myxml.de myxml.xsd"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="myxml"> <!-- Match root of source doc A -->
    <root_of_result_document_C>
    <!-- apply something else -->
    </root_of_result_document_C>
    </xsl:template>
    </xsl:stylesheet>
    I now get an error (comprehensible for me):
    "Root element 'root_of_result_document_C' not defined in DTD/Schema"
    ???

  • Generating xslt with java

    Hi,
    I'm currently working on a project to automatically generate xslt to convert an arbitrary xml file to html....does anyone know if there is a reliable library to generate xsl tags with or will I have to implement this myself....
    thanks in advance,
    Niall.

    Yeah basically the idea is that I'm developing an XML editor and an automatic XSLT generator. The generator should be capable of taking arbitrary xml files and generating xslt files to convert the xml to html.
    Sounds a bit crazy now that I think about it.
    It's actually my final project for college.....if you're interested in the official spec. it's available here:
    http://www.computing.dcu.ie/~ncolem-case4/functionalspec.html
    as usual any suggestions / comments / etc. welcome!
    cheers,
    Niall.

  • Loosing xslt with variable when save in Jdev

    I am using JDeveloper 10.3.3.0.4157. BPEL is deployed on SOA 10.1.3.3.
    As part of a BPEL process I have an xslt transform to populate my outgoing message with a generated guid.
    <xsl:variable name="messageIDVariable" select="orcl:generate-guid()"/>
    <corecom:EBMID>
    <xsl:value-of select="$messageIDVariable"/>
    </corecom:EBMID>
    If I change any part of the transform (like adding new mappings etc), then I save it. I get this error:
    (1):xpath-expression: Error: Variable or parameter "messageIDVariable" is not available for use
    Subsequently the xsl file is saved with my code referring to the variable removed.
    I have deployed this bpel process (with my variable code in it) and it executes successfully filling my output message with the generated guid. So why is Jdev unhappy with it? Is my XSLT incorrect? (I'm new to this stuff so that is very possible). What does "not available for use" mean? It is declared the line above where it is used.
    Go easy on me...like I said I'm new to this stuff.
    Thanks for any insight.

    thanx this is the solution. With this construct
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java">
         <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
         <xsl:template match="/">
         <xsl:variable name="counter" select="java:java.util.Vector.new()"/>
         <xsl:variable name="temp1" select="java:add($counter,'1')"/>
         <xsl:variable name="temp2" select="java:add($counter,'2')"/>
         <xsl:variable name="temp3" select="java:add($counter,'3')"/>
         <xsl:variable name="temp4" select="$temp3"/>
         <xsl:value-of select="java:size($counter)"/>
         <xsl:value-of select="java:toString($counter)"/>
         </xsl:template>
    </xsl:stylesheet>
    at least the '3' is added to the vector.

  • Is XSLT with import/include on database side supported?

    Hi
    I use server side (Oracle 10.2) XSL transformation (in particular DBMS_XSLPROCESSOR package) with source XML and XSLT files stored as XMLType columns. It works Ok. However I did not manage to get it working when importing spreadsheets into XSLT files like this:
    <xsl:import href="generic-elem-to-csv.xslt"/>
    Does Oracle database support Stylesheets with Include and Import to transform XML files on database side?
    Thanks,
    Vlad

    Hi,
    According to your post, my understanding is that you had problems to import the SharePoint SP1 environment site library to SharePoint SP2 environment.
    Alex is right, now we could not import the site from the lower version to the earlier version directly since SharePoint 2010 SP2.
    If you wanted to import the library to the new environment, you should first upgrade the SharePoint environment to the SP2, then export the library.
    Now you can import the library without the issue.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • XSLT with java extensions not working with jdk 1.6

    Hi,
    in as XSL transformation I'm using java functions in some cases. With jdk1.5 this works fine. But when switching to jdk1.6 it seems the java classes are not properly initialized.
    See following simple XSL:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java">
         <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
         <xsl:template match="/">
         <xsl:variable name="counter" select="java:java.util.Vector.new()"/>
         <xsl:variable name="temp1" select="java:add($counter,'1')"/>
         <xsl:variable name="temp2" select="java:add($counter,'2')"/>
         <xsl:variable name="temp3" select="java:add($counter,'3')"/>
         <xsl:value-of select="java:size($counter)"/>
         <xsl:value-of select="java:toString($counter)"/>
         </xsl:template>
    </xsl:stylesheet>
    With jdk 1.5 it creates following output:
    3
    [1, 2, 3]
    With jdk 1.6 I get:
    0
    So I can access the object in jdk 1.6 but adding doesn't work.
    Anybody has an idea what could be wrong or how to fix this?

    thanx this is the solution. With this construct
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xalan/java" exclude-result-prefixes="java">
         <xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
         <xsl:template match="/">
         <xsl:variable name="counter" select="java:java.util.Vector.new()"/>
         <xsl:variable name="temp1" select="java:add($counter,'1')"/>
         <xsl:variable name="temp2" select="java:add($counter,'2')"/>
         <xsl:variable name="temp3" select="java:add($counter,'3')"/>
         <xsl:variable name="temp4" select="$temp3"/>
         <xsl:value-of select="java:size($counter)"/>
         <xsl:value-of select="java:toString($counter)"/>
         </xsl:template>
    </xsl:stylesheet>
    at least the '3' is added to the vector.

Maybe you are looking for

  • How do I stop pages opening in a new tab that I haven't clicked on?

    This page keeps opening in a new tab on my browser even though I have not clicked on anything. It is very annoying and manages to open the new tab and put it as the active tab. I have pop ups disabled and new tabs which open are not supposed to take

  • Saving data typed into a PDF

    Hi folks, There's probably a million questions like this one but I can't concentrate enough right now to try to go through everything. I made a list in Excel, exported it as a PDF. Opened in Adobe Acrobat 9 Pro. Went through the Start Form Wizard, al

  • Can't get updates due to a BPDSoftware problem.

    I don't have this sourse and can't delete it.  Any help?  Thanks  wdopson.    C:\Users\MACKIN~1\AppData\Local\Temp\7zS462A\OJJ4600_Full_14\setup\bpdSoftware\

  • Lightroom 5.3 import crashes while trying accessing a AFP share

    Hello, I am using Lightroom 5.3 on the latest OS X Mavericks 10.9.2. For unknown reasons I can´t access photos which are located on my freenas server on a AFP share. Lightroom got stucked when I opened the folder with the remote images. I deleted thi

  • Log and Transfer with Panasonic HD

    Recently I purchased the Panasonic HDC-HS 100, which is a hybrid SD card/HDD, (AVCHD). I use the Mac OS X (10.4.11) with Final Cut Pro 6.0.5. I am having problems importing my footage onto my computer. When opening the log and transfer window in FCP,