Java code with BSP

Hi Experts,
Is there any way to write java code in BSP pages or to call java code from BSP pages?
Thanks in Advance
Shilpa Dhawan

Hi,
Let there be no misunderstanding.
Java has NOTHING to do with Javascript and vice versa.
Check this like
http://www.htmlgoodies.com/beyond/javascript/article.php/3470971
http://www.dannyg.com/ref/javavsjavascript.html
for the differences
Eddy
PS. Reward the useful answers and you will get <a href="/people/baris.buyuktanir2/blog/2007/04/04/point-for-points-reward-yourself">one point</a> yourself!

Similar Messages

  • Compiling Java code with Japanese characters

    I have a Java code with some Japanese characters. My compiler doesn't recognise these characters and gives me error messages.
    Please help me.

    Obviously it's not the copmiler's fault. You need to fix your code.
    Here is a link to the Java Language Specification.
    The link is to section 3.8 - Identifiers.
    It describes the acceptable naming:
    http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#40625
    Perhaps your editor is not saving the text file in an appropriate format.
    What editor are you using?
    Try vim http://www.vim.org
    or SciTE http://www.scintilla.org/SciTE.html

  • Embedded Java code with bpelx:exec

    When I embed Java code with bpelx:exec, I would like use classes packaged in a jar file. How do I ensure that the jar file is deployed with the suitcase? I tried adding the library to the JDeveloper project (right-click project, choose properties, libraries), but that did not work.

    Although the tooling does not expose this functionality yet, the bpel packaging and bpelc command line tool support the ability to put a library in BPEL-INF/lib and using it in the exec activity. You can also put classes in BPEL-INF/classes. Please look at:
    [ORACLE_HOME]\integration\orabpel\samples\references\JavaExec for more information.
    -Edwin

  • Format Java Code with jdeveloper

    Hi Everybody,
    Can anybody tell me How I can Indent Java Code Automatically using JDeveloper 9i.
    It is a facility which is provided in almost all the editor and I believe it should be in jdeveloper also but the problem is I dont know how to go for it.
    I will be very kind to anybody who will solve this problem as this will reduce my lot of unwanted work.
    Regards,
    Amit Jain

    If you're looking for a code beautifier (a tool that can apply a coding style to your source code automatically), try the Jalopy extension. It's an open source code beautifier that is tightly integrated with JDeveloper:
    http://jalopy.sourceforge.net/plugin-jdev.html
    Thanks,
    Brian
    JDev Team

  • Integrating Java code with pre-existing C application

    My team has been tasked to develop wizards for a pre-existing C application on Unix. We don't own the C code so we can make only limited changes to the native code.
    The challenge is to call the Java wizard from within the C code, and then to allow the Java code to use services and data in the C code. I can call Java from C, and then call C from Java. But the C code that gets called from Java doesn't seem to have access to the data known by the C code that called the Java.
    The only way I've thought of to handle this is to pass function pointers as paramters to the Java program, which can then pass the pointers on to the C code that it calls. Is there a way to pass pointers into Java?

    But the C code that gets called from Java doesn't seem to have access to the data known by the C code that called the Java.
    I don't know exactly what you mean here, unless you're simply saying that the scope of your C data makes it inaccessible between functions.
    Is there a way to pass pointers into Java?
    Yep - Just treat the pointers as opaque types and wrap them in something large enough for the platform - for example a jlong. You need to be sure to be careful in managing the lifetime of the pointers with respect to the Java objects that hold onto them - for example, with function pointers that come from a dynamically loaded shared library or any data pointers that you might be passing around. You probably want to read the section on native peers in the JNI programmer's guide.
    God bless,
    -Toby Reyelts
    Check out the free, open-source, JNI toolkit, Jace - http://jace.reyelts.com/jace

  • How to pass arguments to a batch file from java code

    Hi
    I have a batch file (marcxml.bat) which has the following excerpt :
    @echo off
    if x==%1x goto howto
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; %1 %2 %3
    goto end
    I'm calling this batch file from a java code with the following line of code:
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat");
    so ,that invokes the batch file.Till that point its ok.
    since the batch file accpets arguments(%1 %2 %3) how do i pass those arguments to the batch file from my code ...???
    %1 is a classname : for ex: gov.loc.marcxml.MARC21slim2MARC
    %2 is the name of the input file for ex : C:/Downloads/Marcxml/source.xml
    %3 is the name of the output file for ex: C:/Downloads/Marcxml/target.mrc
    could someone help me...
    if i include these parameters too along with the above line of code i.e
    Process p = Runtime.getRuntime().exec("cmd /c start C:/Downloads/Marcxml/marcxml.bat gov.loc.marcxml.MARC21slim2MARC C:\\Downloads\\Marcxml\\source.xml C:\\Downloads\\Marcxml\\target.mrc") ;
    I get the following error :
    Exception in thread main java.lang.Noclassdef foundError: c:Downloads\marcxml\source/xml
    could some one tell me if i'm doing the right way in passing the arguments to the batch file if not what is the right way??
    Message was edited by:
    justunme1

    1 - create a java class (Executer.java) for example:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    public class Executer {
         public static void main(String[] args) {
              try {
                   for (int i = 0; i < args.length; i++) {
                        System.out.println(args);
                   Class<?> c = Class.forName(args[0]);
                   Class[] argTypes = new Class[] { String[].class };
                   Method main = c.getDeclaredMethod("main", argTypes);
                   // String[] mainArgs = Arrays.copyOfRange(args, 1, args.length); //JDK 6
                   //jdk <6
                   String[] mainArgs = new String[args.length - 1];
                   for (int i = 0; i < mainArgs.length; i++) {
                        mainArgs[i] = args[i + 1];
                   main.invoke(null, (Object) mainArgs);
                   // production code should handle these exceptions more gracefully
              } catch (ClassNotFoundException x) {
                   x.printStackTrace();
              } catch (NoSuchMethodException x) {
                   x.printStackTrace();
              } catch (IllegalAccessException x) {
                   x.printStackTrace();
              } catch (InvocationTargetException x) {
                   x.printStackTrace();
              } catch (Exception e) {
                   e.printStackTrace();
    2 - create a .bat file:
    @echo off
    java -cp C:\Downloads\Marcxml\marc4j.jar; C:\Downloads\Marcxml\marcxml.jar; Executer %TARGET_CLASS% %IN_FILE% %OUT_FILE%3 - use set command to pass variable:
    Open MS-DOS, and type the following:
    set TARGET_CLASS=MyTargetClass
    set IN_FILE=in.txt
    set OUT_FILE=out.txt
    Then run your .bat file (in the same ms dos window)
    Hope that Helps

  • Java code for logging from servlet on AS

    Hi guys,
    I have developed a servlet on SAP AS and I need to log information from processing. Can you please suggest me the best way to do that? I am not an Java expert but when I see the code I'd understand it. Can you please provide some Java logging example code which would work on AS 7.3?
    Thanks a lot,
    Peter

    Hi Peter,
    Please have a look of the below logging links/docs
    Sample Java Code with Logging -  Using Central Development Services - SAP Library
    Tracing and Logging -  SAPNetWeaver Application Server Java Security Guide - SAP Library
    Integrating Third-Party Logging Frameworks into SAP NetWeaver CE
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/20ecb0f4-ccb0-2a10-46aa-ceee8895f34b?QuickLink=index&overridelayout=true&25009594565056
    Or
    You can simply use System.err.println() or System.out.println()
    Thanks,
    Hamendra

  • OpenScript/How to add .jar file to Java Code in relative path

    Hi all,
    I want to add a .jar file which can be executed separately (like "java -jar A.jar") to my recorded Java Code.I've read this wiki http://everest2.us.oracle.com/wiki/Generic_JAR_Project about how to add a .jar file to "Assets", however, I cannot figure out how to use the .jarr file in Java code,I mean , how to get this .jar file like the method the databank added in "Assets"?
    Things I did are as followed:
    1.Execute my .jar file in OpenScript Java code with absolute path like this:
    String cmd = "C:\Users\A.jar";
    Runtime.getRuntime().exec(cmd);
    This does work, but must set a absolute path in Java code like "C:\User\A.jar" ,which is not the workaround I want (I need my scripts can be run on other machines).
    2.Try to get its current path with following codes:
    File directory = new File(".");
    String currentPath=directory.getCanonicalPath();
    However,though this can get its absolute path (which is the the project path) in Eclipse like "C:\Users\Workspace\testProject", this only gets "C:\OracleATS\openScript" in OpenScript.
    I thought to copy my .jar file to the project path , got its current path in java code first,then can know the path of .jar file, but this workaround failed because of the above reason.
    I notice that in the "Assets" there are "Databanks","Object Libraries","JAR Files","Scripts". Since the databanks and scripts that added to "Databanks" and "Scripts" can be got or run in Java Code like:
    *getDatabank("DatabankName").getNextDatabankRecord(); String data = eval("{{db.DatabankName.data}}");*
    *or getScript("ScriptName").run();*
    *Is there a method to get and run the jar file added to "Assets\JAR Files" like the above?*
    Thank you very much!
    Regards,
    Angyoung

    Hi DM,
    Thanks for your reply!
    I've found a workaround,which is calling OpenScript's APIs ,such as this.getScriptPackage().getRepository() and this.getScriptPackage().getWorkspace(),etc to locate the .jar file.
    And this workaround can still work even though the script is run on other machine.
    Sorry to reply you so late!
    Regards,
    Angyoung

  • Java code to convert XML file to ISO XML format

    Hi Experts,
    I need to convert an XML file to ISO Xml format using Java code.I dont have any idea about the ISO XML format.I searched but what i am getting is ISO is an encoding in XML.
    It will be very helpful if any one can give me a sample ISO XML file, and any way around to carry out the required conversion.
    Thanks .
    Anika

    Hi,
    For ISO encoding you need the XML file to be converted with below providing the encoding paramter as ISO. for e.g.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    instead of
    <?xml version="1.0" encoding="UTF-8"?>
    this can be possible with using XML encoders.
    Refer XML encoding--> http://www.w3schools.com/XML/xml_encoding.asp
    Refer Java Code with uasage of XMLEncoder
    http://java.sun.com/j2se/1.4.2/docs/api/java/beans/XMLEncoder.html
    Thanks
    Swarup

  • Where to apply java codes?

    Good Day:
    Perhaps this sound funny....I bought a Java book to learn the coding...pretty interesting...but after all, it didn't tell where can I type and test all those codes.
    After much reading, understand that it should be applied onto the JDK. Am I right? so I went to Java site and downloaded it. But nothing happened? I even borrow some other machine to install the JDK, still the same????
    When I check form control panel, the JDK and JRE successfully install. Pls help. After all, I need to start on where can i test my java codes?
    Many thanks for your reply.

    hellbinder, my apology...i guess you and everyone
    confuse with my question.
    Ok, see, what I need is to type in the code as per
    given in the book i bought. I understand that it got
    to be typing in the JDK in order to be able to test
    it out. So I download the JDK (including JRE & IDE)
    and had it install on my pc. Then now, I still could
    find the JDK (what I think/mean the "text editor"
    here) for me to type in the java codes.
    Or shall I re-phare in in suce, let's imagine, if
    given with a stack of words and fonts, we type in
    note pad may be. then now given with the Java codes,
    where shall i type it? JDK right? thus I installed
    JDK but I couldn't find or launch it to type in those
    Java codes?!
    Thanks!You don't "type in the java codes" in your JDK. You use a texteditor to "type in the java codes" and compile "the java codes" with the compiler from your JDK, and after that you run "the java (byte)codes" with the JRE from your JDK.
    Everything is explained step-by-step in the tutorial I posted earlier. Please take the time to follow those steps.

  • Berkley db java api with replication

    I'm a java programmer/ .NET programmer and consider using berkley db with replication
    my question is two fold :
    1. Basic understanding of berkley db with java api : how exactly does it work ? Is it a single process or multiple process ? this intrigues me since since both java code ( with probably requireds JVM and a dedicated process ) and both c code run together.
    2. when using java api with replication - does each client code in java has to be complied with the berkley db code and run in the same process or can be separate and the database function as a standalone service.
    3. Regarding .NET - what are the possibilities of using berkley db with replication with .NET ?
    Thanks

    Dear Anonymous, :)
    Berkeley DB (the version written in C) can run multi-process and/or multi-threaded when configured to do so (see the docs and look for information on concurrency, locking, and transactions). The Berkeley DB library calls can be wrapped into various languages, the Java Native Interface (JNI) for Java is one. Almost all other languages that I can think of have done something similar. We even use a toolkit called SWIG which helps in the process of wrapping an API for use in another language (nifty stuff). The result is that you can run a Java JVM using the Berkeley DB Java JAR/JNI interface concurrently with any number of other languages (C, Python, Ruby, Perl, TCL, you name it) because they are all simply separate processes using the same Berkeley DB dynamic library at runtime to access the same data. That's it, not much magic just good code. :)
    As to your other two questions:
    2. Berkeley DB HA (aka Replication) allows for two things; read scalability across multiple independent computers, and durability in the face of system failure (if a system dies, another one takes over until it can return to the replication group). Clients in a replication group can run using any language they want, they don't all have to be the same (for the same reasons as before). When running HA each system will manage a complete copy of the database environment (data files, log files, and locking/caching files). One system will be the master (read/write) and the others will be replicas (read only). If a master dies an election is held to determine the new master and then that system (or process) is promoted to master.
    3. There are two answers to your .NET/C# issue. First, were working on an API for 4.8 which will be out soon. Second we just spotted this person's blog entry and found it to be very interesting, you might give it a try with Berkeley DB Java/JNI and see if it works.
    http://maxtoroq.wordpress.com/2008/12/25/hello-berkeley-db-xml-on-net/
    I hope that was helpful and answered your questions,
    -greg

  • Mix jython code with sql

    Hi,
    I have just read the following sentence in the odi jyhon reference:
    "Oracle Data Integrator users may write procedures or knowledge modules using Jython, and may mix Jython code with SQL, PL/SQL, OS Calls, etc."
    Does anyone of you know how jython can be mixed with SQL in a knowledge module? I just know how to embed java code with the <% %> tag. But how about jython (e.g. when used in a knowledge module task with technology = "Oracle"?
    I appreciate your help.
    best regards,
    Hans

    So Firstly I have never done this in KM but it works well in Procedure so I think it would work in a KM but I'm not sure.
    So I will show you an exemple which will be easyer than lot of explanation.
    This exemple is a step of a procedure which is supposed to send an email if there is an error in an execution.
    This Step retrieve informations about the execution as the error message or the execution context...
    In the Target Command :
    Technology= Jython
    I have :
    EmailBody = EmailBody + r'''<TR><TD><CENTER>#NO</CENTER></TD><TD>#SESS_NAME</TD><TD>#STEP_NAME
    </TD><TD>#CONTEXT</TD><TD>#DEBUT</TD><TD>#MSG</TD></TR>'''
    Contexte = '#CONTEXT'.
    --> the #variable are the informations that I will extract in the source.
    In the Source Command :
    Technology = Oracle .
    SELECT L.SESS_NO || ' / ' || L.NNO "NO", STEP_NAME, SESS_NAME, SS.CONTEXT_CODE "CONTEXT", L.STEP_BEG "DEBUT", X.TXT "MSG", L.step_rc "RC"
    FROM <%=snpRef.getObjectName("L", "SNP_STEP_LOG", "D")%> L,
    <%=snpRef.getObjectName("L", "SNP_SESS_STEP", "D")%> SS,
    <%=snpRef.getObjectName("L", "SNP_SESSION", "D")%> S,
    <%=snpRef.getObjectName("L", "SNP_EXP_TXT", "D")%> X
    WHERE L.SESS_NO = <%=snpRef.getSession("SESS_NO")%> AND
    L.SESS_NO = SS.SESS_NO AND L.NNO = SS.NNO AND S.SESS_NO = L.SESS_NO AND
    STEP_STATUS = 'E' and L.I_TXT_STEP_MESS=X.I_TXT and X.TXT_ORD=0
    And with this the Jython keep the information of the Query...
    So I would like to apologize cause in my last post I have inversed the Target and the Source... Sorry. Hope that your problem didn't come from here...
    Evidently you will have SQL as Source and Jython as Target...

  • Problem in printing pdf document with java code

    Hi All
    I want to print a pdf document with java code i have used PDFRenderer.jar to compile my code.
    Code:
    File f = new File("C:/Documents and Settings/123/Desktop/1241422767.pdf");
    FileInputStream fis = new FileInputStream(f);
    FileChannel fc = fis.getChannel();
    ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page
    PDFPrintPage pages = new PDFPrintPage(pdfFile);
    // Create Print Job
    PrinterJob pjob = PrinterJob.getPrinterJob();
    PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
    pjob.setJobName(f.getName());
    Book book = new Book();
    book.append(pages, pf, pdfFile.getNumPages());
    pjob.setPageable(book);
    // System.out.println(pjob.getPrintService());
    // Send print job to default printer
    pjob.print();
    but when i am running my program i am getting error
    Exception in thread "main" java.awt.print.PrinterException: Invalid name of PrintService.
    Please anybody, knows the solution for this error?
    Thanks In Advance
    Indira

    It seems that either there is no default printer setup or you have too many printers or no printer setup at all. Try running the following code. It should print the list of available print services.
    import java.awt.print.*;
    import javax.print.*;
    public class PrintServiceNames{
         public static void main(String args[]) throws Exception {
              PrintService[] printServices = PrinterJob.lookupPrintServices();
              int i;
              for (i = 0; i < printServices.length; i++) {
                   System.out.println("P: " + printServices);
    }From the list pick one of the print service names and set it explicitly like "printerJob.setPrintService(printServices);" and then try running the program.

  • How to display pdf file with java code?

    Hi All,
    i have a jsp pagein that page if i click one icon then my backing bean method will call and that method will create pdf document and write some the content in that file and now i want to display that generated pdf document.
    it should look like you have pressed one icon and it displayed pdf file to you to view.
    java code below:
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "filename=\"" + temppdfFile);
    resp.encodeRedirectURL(temppdfFile.getAbsolutePath());
    resp.setContentType("application/pdf");
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(temppdfFile, out);
    out.flush();
    and above temppdfFile is my generated pdf file.
    when i am executing this code, it was opening dialog box for save and cancel for the file, but the name of the file it was showing me the "jsp file name" with no file extention (in wich jsp file i am calling my backing bean method) and type is "Unknown File type" and from is "local host"
    it was not showing me open option so i am saving that file then that file saved as a pdffile with tha name of my jsp file and there is nothing in that file(i.e. empty file).
    what is the solution for this. there is any wrong in my code.
    Please suggest me.
    Thanks in advance
    Indira

    public Object buildBarCodes() throws Exception
    File bulkBarcodes = null;
    String tempPDFFile = this.makeTempDir();
    File tempDir = new File("BulkPDF_Files_Print");
    if(!tempDir.exists())
    tempDir.mkdir();
    bulkBarcodes = File.createTempFile
    (tempPDFFile, ".pdf", tempDir);
    //bulkBarcodes = new File(tempDir, tempPDFFile+"BulkBarcode"+"."+"pdf");
    if(!bulkBarcodes.exists())
    bulkBarcodes.createNewFile();
    Document document = new Document();
    FileOutputStream combinedOutput = new FileOutputStream(bulkBarcodes);
    PdfWriter.getInstance(document, combinedOutput);
    document.open();
    document.add(new Paragraph("\n"));
    document.add(new Paragraph("\n"));
    Image image = Image.getInstance(bc.generateBarcodeBytes(bc.getBarcode()));
    document.add(image);
    combinedOutput.flush();
    document.close();
    combinedOutput.close();
    FacesContext facesc = FacesContext.getCurrentInstance();
    ExternalContext ec = facesc.getExternalContext();
    HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
    resp.setHeader("Content-Disposition", "inline: BulkBarcodes.pdf");
    resp.encodeRedirectURL(bulkBarcodes.getAbsolutePath());
    resp.setContentType("application/pdf");
    resp.setBufferSize(10000000);
    ServletOutputStream out = resp.getOutputStream();
    ServletUtils.returnFile(bulkBarcodes, out);
    out.flush();
    return "success";
    This is my action method which will call when ever i press a button in my jsp page.
    This method will create the barcode for the given barcode number and write that barcode image in pdf file
    (i saw that pdf file which i have created through my above method, This PDF file opening when i was opening manually and the data init that is also correct means successfully it writes the mage of that barcode)
    This method taking the jsp file to open because as earlier i said it was trying to open unknown file type document and i saved that file and opended with editplus and that was the jsp file in which file i am calling my action method I mean to say it was not taking the pdf file which i have created above it was taking the jsp file

  • Unable to transform XML with XSL in java code

    Hi,
    Could somebody please tell me what's wrong with my code, why it isn't transform the XML with XSL to the output that I want. If I use the command line to transform the XML, it output perfectly:
    java org.apache.xalan.xslt.Process -in marc.xml -xsl MARC21slim2MODS.xsl -out out.xml
    Here is the code of my program to transform the XML with XSL, I am using xalan-j_2_2-bin:
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import org.w3c.dom.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import javax.xml.transform.dom.*;
    import java.math.BigInteger;
    String xslDoc = "MODS.xsl";
    String xmlResult = "out.xml";
    DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
    dfactory.setNamespaceAware(true);
    DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
    Document xmlDoc = docBuilder.newDocument();
    Element root = xmlDoc.createElement("collection");
    root.setAttribute("xmlns", "http://www.loc.gov/MARC21/slim");
    xmlDoc.appendChild(root);
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(new StreamSource(xslDoc));
    FileWriter fw = new FileWriter(new File(xmlResult));
    StreamResult output = new StreamResult(fw);
    transformer.transform(new DOMSource(xmlDoc), output);
    fw.flush();
    fw.close();
    ========================
    marc.xml -- source XML file
    ========================
    <?xml version="1.0" encoding="UTF-8"?>
    <collection xmlns="http://www.loc.gov/MARC21/slim"><record><leader>01488cam 2200337 a 4500</leader><controlfield tag="001">2502929</controlfield><controlfield tag="005">19930521155141.9</controlfield><controlfield tag="008">920219s1993 caua j 000 0 eng </controlfield><datafield ind1=" " ind2=" " tag="035"><subfield code="9">(DLC) 92005291</subfield></datafield><datafield ind1=" " ind2=" " tag="906"><subfield code="a">7</subfield><subfield code="b">cbc</subfield><subfield code="c">orignew</subfield><subfield code="d">1</subfield><subfield code="e">ocip</subfield><subfield code="f">19</subfield><subfield code="g">y-gencatlg</subfield></datafield>
    </record></collection>
    ========================
    out.xml -- result using command line
    ========================
    <?xml version="1.0" encoding="UTF-8"?>
    <collection xmlns="http://www.loc.gov/mods/" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/ http://www.loc.gov/standards/marcxml/schema/mods.xsd">
    <mods>
    <titleInfo>
    <title>Arithmetic</title>
    </titleInfo>
    <name type="personal">
    <namePart>Sandburg, Carl</namePart>
    <namePart type="date">1878-1967</namePart>
    <role>creator</role>
    </name>
    </mods>
    </collection>
    ========================
    out.xml -- result using my java program
    ========================
    <?xml version="1.0" encoding="UTF-8"?>
    <collection xmlns="http://www.loc.gov/mods/" xmlns:xlink="http://www.w3.org/TR/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/ http://www.loc.gov/standards/marcxml/schema/mods.xsd">01488cam 2200337 a 4500250292919930521155141.9920219s1993 caua j 000 0 eng (DLC) 920052917cbcorignew1ocip19y-gencatlgpc16 to br00 02-19-92; br02 to SCD 02-21-92; fd11 02-24-92 (PS3537.A618 A...); fa00 02-26-92; fa05 03-02-92; fm31 03-06-92; CIP ver. pv08 04-16-93; pv01 to CLT 04-20-93; lb10 05-21-93
    </collection>

    I am using the same XSL file. My Java program use the same XSL file I used in the command line.
    It is possible that my Java code is using a different parser, but I developed a seperate program to parse the XML using the same parser that my Java code is using. It output the result I expected. Here is the code for the program:
    import java.io.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    public class Convertor {
    public static void main(String[] args) throws Exception {
    String xslDoc = "MARC21slim2MODS.xsl";
    String xmlResult = "out.xml";
    String xmlDoc = marc.xml";
    TransformerFactory factory = TransformerFactory.newInstance();
    Transformer transformer = factory.newTransformer(new StreamSource(xslDoc));
    StreamSource xmlSource = new StreamSource(xmlDoc);
    FileWriter fw = new FileWriter(new File(xmlResult));
    StreamResult output = new StreamResult(fw);
    transformer.transform(xmlSource, output);
    }

Maybe you are looking for