Split XML files with XSL result document

Hi All,
I have below xml file...
<?xml version="1.0" encoding="ISO-8859-1"?>
<T0020
xsi:schemaLocation="http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.safersys.org/namespaces/T0020V1">
<INTERFACE>
<NAME>SAFER</NAME>
<VERSION>04.02</VERSION>
</INTERFACE>
<TRANSACTION>
<VERSION>01.00</VERSION>
<OPERATION>REPLACE</OPERATION>
<DATE_TIME>2009-09-01T00:00:00</DATE_TIME>
<TZ>CT</TZ>
</TRANSACTION>
<IRP_ACCOUNT>
<IRP_CARRIER_ID_NUMBER>274845</IRP_CARRIER_ID_NUMBER>
<IRP_BASE_COUNTRY>US</IRP_BASE_COUNTRY>
<IRP_BASE_STATE>AR</IRP_BASE_STATE>
<IRP_ACCOUNT_NUMBER>55002</IRP_ACCOUNT_NUMBER>
<IRP_ACCOUNT_TYPE>I</IRP_ACCOUNT_TYPE>
<IRP_STATUS_CODE>100</IRP_STATUS_CODE>
<IRP_STATUS_DATE>2007-11-06</IRP_STATUS_DATE>
<IRP_UPDATE_DATE>2009-08-03</IRP_UPDATE_DATE>
<IRP_NAME>
<NAME_TYPE>LG</NAME_TYPE>
<NAME>A P SUPPLY CO</NAME>
<IRP_ADDRESS>
<ADDRESS_TYPE>PH</ADDRESS_TYPE>
<STREET_LINE_1>1400 N OATS</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>71854</ZIP_CODE>
<COUNTY>MILLER</COUNTY>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
<IRP_ADDRESS>
<ADDRESS_TYPE>MA</ADDRESS_TYPE>
<STREET_LINE_1>P O BOX 1927</STREET_LINE_1>
<STREET_LINE_2/>
<CITY>TEXARKANA</CITY>
<STATE>AR</STATE>
<ZIP_CODE>75504</ZIP_CODE>
<COUNTY/>
<COLONIA/>
<COUNTRY>US</COUNTRY>
</IRP_ADDRESS>
</IRP_NAME>
</IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
and i want to take this xml file and split it into multiple files through java code like this ...
File1.xml
<T0020>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
File2.xml
<T0020>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
<IRP_ACCOUNT> ..... </IRP_ACCOUNT>
</T0020>
so i have applied following xslt ...
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.safersys.org/namespaces/T0020V1" version="2.0">
<xsl:output method="xml" indent="yes" name="xml" />
<xsl:variable name="accounts" select="t:T0020/t:IRP_ACCOUNT" />
<xsl:variable name="size" select="10" />
<xsl:template match="/">
<xsl:for-each select="$accounts[position() mod $size = 1]">
<xsl:variable name="filename" select="resolve-uri(concat('output/',position(),'.xml'))" />
<xsl:result-document href="{$filename}" format="xml">
<T0020>
<xsl:for-each select=". | following-sibling::t:IRP_ACCOUNT[position() < $size]">
<xsl:copy-of select="." />
</xsl:for-each>
</T0020>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Now i want to apply this XSL to xml through Java Code...
TransformerFactory tFactory = TransformerFactory.newInstance();
Source xslSource = new StreamSource(xslFilePath);
Transformer trans = tFactory.newTransformer(xslSource);
trans.transform(new StreamSource(xmlFileName), new StreamResult( ????));
here how can i map new StreamResult( ) input parameter with xsl Result document argument ??
Please help me.....
Or Can you give me a link of Example which use result document and Java transform method to Output multiple doucment ??
Here new StreamResult take only 1 file as to be transformed ....

hi Tejas ,
I have done as you said but now able to generate multiple xml file .
I am giving you the xsl file i have used ....
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.safersys.org/namespaces/T0020V1" version="2.0">
     <xsl:output method="xml" indent="yes" name="xml" />
     <xsl:variable name="accounts" select="t:T0020/t:IRP_ACCOUNT" />
     <xsl:variable name="size" select="5" />
     <xsl:template match="/">
          <xsl:for-each select="$accounts[position() mod $size = 1]">
               <xsl:variable name="filename" select="concat(position(),'.xml')" />
                    <xsl:result-document href="{$filename}" format="xml">
                         <T0020>
                              <xsl:for-each select=". | following-sibling::t:IRP_ACCOUNT[position() < $size]">
                                   <xsl:copy-of select="." />
                              </xsl:for-each>                              
                         </T0020>
                    </xsl:result-document>                    
          </xsl:for-each>
     </xsl:template>
</xsl:stylesheet>
and i have done transformation like this ...
Transformer trans = tFactory.newTransformer(xslSource);
trans.transform(new StreamSource(xmlFileName), new DOMResult());
but not getting any result .
Can you please help me out ?
- Nisarg

Similar Messages

  • Transfer 100M XML file with XSL

    Hi,
    I am trying to transfer 100M XML file with XSL. Input.xml is the XML file, format.xsl is the XSL file. I type in the command line as:
    java org.apache.xalan.xslt.Process -IN input.xml -XSL format.xsl -OUT output.xml
    It got "out of memeory" error. My questions are:
    1. Is it possible to transfer such large XML file with XSLT?
    2. The XSL processor used SAX or DOM to parse XML file?
    3. Any suggestions?
    Thanks.
    James

    maybe?
    java -Xmx200m org.apache.xalan.xslt.Process -IN input.xml -XSL format.xsl -OUT output.xml
    http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java-classic.html

  • Transform Large XML files with XSL

    HELP, LARGE XML FILES
    I have got 30 - 50 MB large xml file, and i would like to transform it
    with xslt, i tried but i have got OutOfMemory Exception.
    I tried to find out the solution on JAVA site, but i didn't find it.
    I can not displit my xml file. I hope for some help.
    I tried really everything.
    Thanks a lot

    What is your machine configuration ?
    The above 2 suggestions would help, but it does depend on how your software is written.
    Please post more info about your environment and object design.
    Chintan

  • Xml file with xsl style sheet reference

    I am trying to learn this from a book, I copied the code like
    it shows, but the page on the server keeps coming back with an
    error starting on line 54 involving the four "End If" quotes. I
    have tried everything I can think of and can't get it to work. Any
    help would be greatly appreciated.
    Here's the code:
    <%@Language=VBScript%>
    <%option explicit%>
    <%
    dim domDoc
    dim aFilename
    Dim node
    Dim nodes
    dim mainNodes
    dim mainnode
    dim attr
    dim root
    Set domDoc = Server.CreateObject("MSXML.DOMDocument")
    afilename =server.MapPath("ch19i1.xml")
    if not domDoc.load(afilename) then
    Response.Write "Could not load the file " & aFilename
    & "<br>"
    Response.End
    end if
    %>
    <html>
    <head></head>
    <body>
    <%
    ' display the root node
    set root = domDoc.documentElement
    Response.Write "<h1>" & root.nodename & ": "
    & root.nodevalue & "</h1>"
    Set mainNodes = root.childNodes
    For Each mainNode in mainNodes
    If mainNode.hasChildNodes = False Then
    Response.Write "<h2>" & mainNode.nodeName & ":
    " & mainNode.text & "</h2><br>"
    Else
    Response.Write "<h3>" & mainNode.nodeName & ":
    " & mainNode.text & "</h3>"
    Set nodes = mainNode.childNodes
    If nodes.lenght > 0 Then
    Set node = nodes(0)
    If Not node.Attributes Is Nothing Then
    If node.Attributes.lenght > 0 Then
    Response.Write "<table border='1'>"
    Response.Write "<thead>"
    For Each attr In node.Attributes
    Response.Write "<th>" & attr.nodeName &
    "</th>"
    Next
    Response.Write "</tr>"
    For Each node In nodes
    Response.Write "<tr>"
    For Each attr In node.Attributes
    If attr.nodeValue = "" Then
    Response.Write "<td>" & " " &
    "</td>"
    Else
    Response.Write "<td>" & attr.nodeValue &
    "</td>"
    End If
    Next
    Response.Write "</table>"
    End If
    End If
    End IF
    End If
    Next
    %>
    </body>
    </html>

    Is the error message displayed in Firefox or in IE, or in a customized window that doesn't identify the browser?
    ''If it displays in Firefox:''
    It's possible that the Troubleshooter doesn't work correctly unless IE is your default browser. You could test that possibility by having IE make itself the default and testing the Troubleshooter again.
    ''If it displays in IE or embedded in another Microsoft application:''
    In a web search I found these suggestions:
    (1) Reset your Internet Explorer settings, according to http://answers.microsoft.com/en-us/ie/forum/ie8-windows_7/cannot-view-xml-using-xsl-style-sheet/ccfe80c6-c0db-4594-a7e3-475f9eac0e85
    (2) Try the System File Checker, according to http://ask-leo.com/why_do_i_get_the_xml_page_cannot_be_displayed_after_running_a_microsoft_troubleshooter.html
    Any luck?

  • Issue with reading a xml file from xsl

    Hi,
    When I am trying to read a xml file from xsl, I am getting unwanted output.
    Following is the XSL:
    <?xml version="1.0" encoding="UTF-8" ?>
    <?oracle-xsl-mapper
      <!-- SPECIFICATION OF MAP SOURCES AND TARGETS, DO NOT MODIFY. -->
      <mapSources>
        <source type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </source>
      </mapSources>
      <mapTargets>
        <target type="XSD">
          <schema location="../xsd/B2BMarketProperties.xsd"/>
          <rootElement name="ReceipentIDType" namespace="http://www.example.org"/>
        </target>
      </mapTargets>
      <!-- GENERATED BY ORACLE XSL MAPPER 11.1.1.4.0(build 110106.1932.5682) AT [TUE DEC 03 16:06:03 EST 2013]. -->
    ?>
    <xsl:stylesheet version="1.0"
                    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
                    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
                    xmlns:mhdr="http://www.oracle.com/XSL/Transform/java/oracle.tip.mediator.service.common.functions.MediatorExtnFunction"
                    xmlns:bpel="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
                    xmlns:oraext="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xmlns:ns0="http://www.example.org"
                    xmlns:dvm="http://www.oracle.com/XSL/Transform/java/oracle.tip.dvm.LookupValue"
                    xmlns:hwf="http://xmlns.oracle.com/bpel/workflow/xpath"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:med="http://schemas.oracle.com/mediator/xpath"
                    xmlns:ids="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
                    xmlns:bpm="http://xmlns.oracle.com/bpmn20/extensions"
                    xmlns:xdk="http://schemas.oracle.com/bpel/extension/xpath/function/xdk"
                    xmlns:xref="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:ora="http://schemas.oracle.com/xpath/extension"
                    xmlns:socket="http://www.oracle.com/XSL/Transform/java/oracle.tip.adapter.socket.ProtocolTranslator"
                    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
                    exclude-result-prefixes="xsi xsl ns0 xsd bpws xp20 mhdr bpel oraext dvm hwf med ids bpm xdk xref ora socket ldap">
      <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
      <xsl:variable name="ReceipentID" select="document('../xsd/B2BMarketProperties.xml')"/>
      <xsl:template match="/">
        <ns0:ReceipentIDType>
        <xsl:for-each select="$ReceipentID">
          <ns0:ReceipentID>
            <xsl:value-of select="$ReceipentID"/>
          </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>
    </xsl:stylesheet>
    Following is the XML ( B2BMarketProperties.xml)
    <?xml version="1.0" encoding="UTF-8" ?>
    <ReceipentIDType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xsi:schemaLocation="http://www.example.org B2BMarketProperties.xsd"
                     xmlns="http://www.example.org">
      <ReceipentID>123</ReceipentID>
      <ReceipentID>345</ReceipentID>
    </ReceipentIDType>
    The output i am getting with this code is
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    But, I need output in the following format
    <ns0:ReceipentIDType xmlns:ns0="http://www.example.org">
        <ns0:ReceipentID>123</ns0:ReceipentID>
         <ns0:ReceipentID>345</ns0:ReceipentID>
    </ns0:ReceipentIDType>
    Could you guys let me know what i am doing wrong. Any help would be appreciated.
    Thanks,

    This worked for me :
      <xsl:template match="/">
        <ns0:ReceipentIDType>
          <xsl:for-each select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID">
            <xsl:variable name="count" select="position()"/>
            <ns0:ReceipentID>
              <xsl:value-of select="document('B2BMarketProperties.xml')/*:ReceipentIDType/*:ReceipentID[$count]"/>
            </ns0:ReceipentID>
          </xsl:for-each>
        </ns0:ReceipentIDType>
      </xsl:template>

  • Read an XML file with java: Document to Node conversion

    Hello,
    I want to read an XML file and convert data into a Node instance because I need this for an XForm application.
    My code is:
    private Node workstationType;
    public Node initModel() {
    try {
    //This one will hold the results
    Document document;
    //loading from XML File
    String fileName="C:\\documents\\iniForm.xml";
    FileInputStream inXML = new FileInputStream(fileName);
    BufferedReader in = new BufferedReader(new InputStreamReader(inXML));
    document = XMLLoader.loadFromStream(in);
    } catch (Exception e) {
    System.err.println("ERROR:" + e.getMessage());
    e.printStackTrace(System.err);
    //Create the node for the root, 'typeOfWorkstation'
    workstationType = document.getDocumentElement(); //A
    //Return the root node
    return (workstationType);
    The problem: I can convert Node instance to Document instance (line A)
    The error message is: "document cannot be resolved".
    How can I do that??
    Thank you
    Sylvain

    Here is my XMLLoader class:
    public class XMLLoader {
         public static Document loadFromStream(Reader reader) throws Exception {
              //Build a DOM document with the reader
              //prepare DOM document
              DOMImplementation impl;
              DocumentBuilder builder;
              try {
                   // Find the implementation
                   DocumentBuilderFactory factory =
                        DocumentBuilderFactory.newInstance();
                   factory.setNamespaceAware(false);
                   factory.setValidating(false);
                   builder = factory.newDocumentBuilder();
                   impl = builder.getDOMImplementation();
                   //Read and parse the XML input stream into a DOM document
                   Document document = builder.parse(new InputSource(reader));
                   return document;
              } catch (IOException ex) {
                   throw new RuntimeException(
                        "[XMLLoader.loadFromFile]: Failed loading the InputStream. Root cause: \n"
                             + ex);
              } catch (Exception ex) {
                   throw new RuntimeException(
                        "[XMLLoader.loadFromFile]: Failed to initialize DOM factory. Root cause: \n"
                             + ex);

  • Xml file with embedded xsl reports unknow error: An unknown error has occurred (805303f4)

    Hi,
    I have an xml file with embedded xsl link like below :
    XML :
    <pre><nowiki><?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="http://abc.com/x.xsl"?>
    <catalog>
    <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
    </cd>
    </catalog></nowiki></pre>
    When opening xml file on IE, opera, safary ... it works ok. But when opening it on FireFox, i have an error like :
    Error loading stylesheet: An unknown error has occurred (805303f4)
    http://abc.com/x.xsl
    How could i solve this problem ?

    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.
    The helpers at that forum are more knowledgeable about web development issues.
    You need to register at the mozillaZine forum site in order to post at that forum.
    See http://forums.mozillazine.org/viewforum.php?f=25

  • Combine several XML files with same structure

    Hello,
    I have several XML files with the same structure and I want to combine them and create a new XML file to be bale to compare that information easily. It does not look very difficult but as I am very new in this I am not bale to get it
    The structure of my actual files would be something simlar to:
    Root->...-> Name->Address, Telephone
    And what I would like to have si something like
    Root->.... ->Address-> Name 1,Name 2....
    Root -> ...->Telephone-> Name 1, Name 2....
    Does anyone know how to do this.
    Thanks

    You could write a XSL transformation file that does this and transform your input file via
         * Transform XML file with a style sheet.
         * <p><b>Example:</b><p>
    <table align="center" bgcolor="#E0E0E0" border=1 cellpadding="10" cellspacing="0"><tr><td><pre style="margin-top:0; margin-bottom:0">
    XMLTransformer t = new XMLTransformer();
    FileOutputStream fos = new FileOutputStream("C:/Project/result.html");
    String xmlFile = "C:/Project/source.xml";
    String styleSheet = "C:/Project/stylesheet.xsl";
    t.transform(xmlFile, styleSheet, fos);
    </pre></td></tr></table>
         * @param xmlfile The XML file to transform.
         * @param style Stylesheet to use for transformation.
         * @param outputStream OutputStream to write the transformed result to.
        public void transform(String xmlfile, String style, OutputStream outputStream) {
            DocumentBuilderFactory factory =  DocumentBuilderFactory.newInstance();
            //factory.setNamespaceAware(true);
            //factory.setValidating(true);
                //todo: use inputstreams instead of file names
                try {
                    File stylesheet = new File(style);
                    File datafile   = new File(xmlfile);
                    DocumentBuilder builder = factory.newDocumentBuilder();
                    document = builder.parse(datafile);
                    // Use a Transformer for output
                TransformerFactory tFactory = TransformerFactory.newInstance();
                StreamSource stylesource = new StreamSource(stylesheet);
                Transformer transformer = tFactory.newTransformer(stylesource);
                DOMSource source = new DOMSource(document);
                StreamResult sr = new StreamResult(outputStream);
                transformer.transform(source, sr);
            } catch (TransformerConfigurationException tce) {
               // Error generated by the parser
               System.out.println ("\n**XMLTransformerr Factory error");
               System.out.println("   " + tce.getMessage() );
               // Use the contained exception, if any
               Throwable x = tce;
               if (tce.getException() != null) {
                   x = tce.getException();
               x.printStackTrace();
            } catch (TransformerException te) {
               // Error generated by the parser
               System.out.println ("\n** Transformation error");
               System.out.println("   " + te.getMessage() );
               // Use the contained exception, if any
               Throwable x = te;
               if (te.getException() != null) {
                   x = te.getException();
               x.printStackTrace();
             } catch (SAXException sxe) {
               // Error generated by this application
               // (or a parser-initialization error)
               Exception  x = sxe;
               if (sxe.getException() != null) {
                   x = sxe.getException();
               x.printStackTrace();
            } catch (ParserConfigurationException pce) {
                // Parser with specified options can't be built
                pce.printStackTrace();
            } catch (IOException ioe) {
               // I/O error
               ioe.printStackTrace();
        }//transform()

  • Read XML file with JSX

    I would like to be able to read an XML file in an InDesign script and create a new document by looping through its nodes and extracting content from them. I've never done this before and I can't seem to find the right information on how to do it. Can someone give me a snippet to get me started? Thanks!

    Read the "Integrating XML into JavaScript" chapter in "JavaScript Tools Guide".
    Below is a script I made a while ago. It can give you idea how to start writing your own script. It reads an xml-file, creates a new document from the template, relinks links listed in the xml-file comparing the width, height and resolution with data in the xml-file.
    // Copyright 2011, «Студия Форма»
    // October 3, 2011
    // Written by Kasyan Servetsky
    // http://www.kasyan.ho.com.ua
    // e-mail: [email protected]
    //==================================== GLOBALS ==========================================
    var gErrMsgArr = [];
    //=======================================================================================
    Main();
    //=================================== FUNCTIONS  =========================================
    function Main() {
        var montage, doc, docFile, component, noErrors, pdfPath, pdfFile, targetPagesLength, destinationFolder;
        var currentFolder = Folder.selectDialog("Выберите текущую папку");  //new Folder("/D/Evgen/");
        if (currentFolder == null) exit();
        var currentFolderPath = currentFolder.absoluteURI + "/";
        var xmlFile = new File(currentFolderPath + "!sforder.xml");
        if (!xmlFile.exists) exit();   
        var outFolderPath = "~/Desktop/Output/";
        var outFolder = new Folder(outFolderPath);
        if (!outFolder.exists) outFolder.create();
        xmlFile.open("r");
        var xmlStr = xmlFile.read();
        xmlFile.close();
        var root = new XML(xmlStr);
        default xml namespace = "http://www.forma-studio.com/order";
        var linksArr = [];
        var componentList = root.xpath("/order/product/components/component");
        var componentsLength = componentList.length();   
        for (var c = 0; c < componentsLength; c++) {
            component = componentList[c];
            linksArr.push({ name : component.images.image.file_name.toString(),
                                width : parseInt(component.images.image.size.width),
                                height : parseInt(component.images.image.size.height),
                                resolution : parseInt(component.images.image.resolution),
        var montageList = root.xpath("/order/product/montages/montage");
        var montagesLength = montageList.length();
        for (var i = 0; i < montagesLength; i++) {
            montage = montageList[i];
            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;       
            app.open(new File(montage.layout_filename));
            doc = app.activeDocument;
            docFile = new File(outFolderPath + montage.result_filename + ".indd");
            doc.save(docFile);
            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
            targetPagesLength = parseInt(montage.page_count);
            if (!isNaN(targetPagesLength)) {
                //$.writeln("About to remove pages - " + doc.name + " - " + montage.page_count);
                while (doc.pages.length > targetPagesLength) {
                    doc.pages.lastItem().remove();
            UpdateAllOutdatedLinks(doc);
            noErrors = ProcessDoc(doc, linksArr, currentFolderPath);
            if (noErrors) {
                destinationFolder = new Folder(montage.destination);
                VerifyFolder(destinationFolder);
                pdfPath = montage.destination + "/" + montage.result_filename + ".pdf"
                pdfFile = new File(pdfPath);
                doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, "[High Quality Print]");
            doc.close(SaveOptions.YES);
    function ProcessDoc(doc, linksArr, currentFolderPath) {
        var link, linkFile;
        var noErrors = true;
        var links = doc.links;
    //~     $.writeln("--------------------------");
    //~     $.writeln(doc.name);
        for (var i = links.length-1; i >= 0; i--) {
            link = doc.links[i];
            for (var o = 0; o < linksArr.length; o++) {
                if (link.name == linksArr[o].name) {
                    linkFile = new File(currentFolderPath + linksArr[o].name);
                    if (linkFile.exists) {
    //~                     $.writeln("\t" + o + " - " + linkFile.name + " - linkFile.exists");
                        if (CheckLink(link, linksArr[o], doc) == false) noErrors = false;
                        link.relink(linkFile);
                    else {
                        $.writeln(o + " - " + linkFile.name + " - linkFile doesn't exist");
                        noErrors = false;
    //~     $.writeln("--------------------------");
        return noErrors;
    function CheckLink(link, linkObj, doc) {
        var errMessage;   
        var result = true;
        var image = link.parent;
        var actualPpi = image.actualPpi;
        var md = link.linkXmp;
        var reportFilePath = doc.fullName.absoluteURI.replace(/\.indd$/i, ".txt");
        var width = parseInt(md.getProperty("http://ns.adobe.com/exif/1.0/", "exif:PixelXDimension"));
        var height = parseInt(md.getProperty("http://ns.adobe.com/exif/1.0/", "exif:PixelYDimension"));
        if (actualPpi[0] != linkObj.resolution && actualPpi[1] != linkObj.resolution) {
            errMessage = link.name + " - resolution is NOT correct: " + actualPpi[0] + "/" + actualPpi[1] + " ppi instead of " + linkObj.resolution + "\r";
            if (IsInArray(errMessage, gErrMsgArr) == false) {
                gErrMsgArr.push(errMessage);           
                //$.writeln(errMessage);
                WriteToFile(errMessage, reportFilePath);
                result = false;   
        if (height != linkObj.height) {
            errMessage = link.name + " - height is NOT correct: " + height + " pixels instead of " + linkObj.height + "\r";
            if (IsInArray(errMessage, gErrMsgArr) == false) {
                gErrMsgArr.push(errMessage);           
                //$.writeln(errMessage);
                WriteToFile(errMessage, reportFilePath);
                result = false;   
        if (width != linkObj.width) {
            errMessage = link.name + " - width is NOT correct: " + width + " pixels instead of " + linkObj.width + "\r";
            if (IsInArray(errMessage, gErrMsgArr) == false) {
                gErrMsgArr.push(errMessage);           
                //$.writeln(errMessage);
                WriteToFile(errMessage, reportFilePath);
                result = false;   
        return result;
    function UpdateAllOutdatedLinks(doc) {
        var link;
        for (var i = doc.links.length-1; i >= 0; i--) {
            link = doc.links[i];
            if (link.status == LinkStatus.LINK_OUT_OF_DATE) link.update();
    function WriteToFile(text, reportFilePath) {
        file = new File(reportFilePath);
        file.encoding = "UTF-8";
        if (file.exists) {
            file.open("e");
            file.seek(0, 2);
        else {
            file.open("w");
        file.write(text);
        file.close();
    function GetDate() {
        var date = new Date();
        if ((date.getYear() - 100) < 10) {
            var year = "0" + new String((date.getYear() - 100));
        else {
            var year = new String((date.getYear() - 100));
        var dateString = (date.getMonth() + 1) + "/" + date.getDate() + "/" + year + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
        return dateString;
    function ErrorExit(error, icon) {
        alert(error, gScriptName + " - " + gScriptVersion, icon);
        exit();
    function IsInArray(string, arr) {
        for (x in arr) {
            if (string.toLowerCase() == arr[x].toLowerCase()) {
                return true;
        return false;
    function VerifyFolder(folder) {
        if (!folder.exists) {
            var folder = new Folder(folder.absoluteURI);
            var arr1 = new Array();
            while (!folder.exists) {
                arr1.push(folder);
                folder = new Folder(folder.path);
            var arr2 = new Array();
            while (arr1.length > 0) {
                folder = arr1.pop();
                if (folder.create()) {
                    arr2.push(folder);
                } else {
                    while (arr2.length > 0) {
                        arr2.pop.remove();
                    throw "Folder creation failed";

  • Open XML file with user default browser and not the default editor.

    Hi,
    I'm writing a java program that appends numerous XML files together. The result is a NEW well formed XML document. Since i have an XSLT that performs several UI modifications on this xml file, the file extension must remain '.xml'. I need to open this xml file with the users default web browser. The problem is that:
    Runtime.getRuntime().exec(cmd);
    ....opens the xml file with the users default program for opening xml files which in my case is Oxygen. I want to force java to open this xml file with the users default web browser and nothing else.
    I guess i need the Windows command to perform the 'open with' feature but i have no idea what that command is or how to find it.
    Any ideas?
    Thanks,
    Varun Singh
    Edited by: Jagara00 on Jul 2, 2009 3:49 PM

    sabre150 wrote:
    Jagara00 wrote:
    Your right, but my question relates to the java issue and not the XSLT aspect of the problem. I am looking for a java solution for reasons i will no go into here. You have lost me.Me too.
    People do not often ask questions (or make challenges or observations) idly for the sake of 'theory'. It is most useful to explain to the best of your ability.
    As to
    "Since the Desktop class was only released with SE 6 I am forced to find another alternative. "
    There is an 'alternative'. You can import it into a 1.5 project. It was available as a free standing API before 1.6 - through JDIC. See [https://jdic.dev.java.net/documentation/Examples.html|https://jdic.dev.java.net/documentation/Examples.html] for more info.
    Edit 1:
    To a later reply
    "Do u .."
    ..want to spell incorrectly when you get frustrated?
    "..do not wish to.."
    ..get any help? That is the way you are heading.
    Edited by: AndrewThompson64 on Jul 3, 2009 9:27 AM

  • I am trying to create a print ready PDF from a word file with unacceptable results.

    I am trying to create a print ready PDF from a word file with unacceptable results.
    The word file has a trim size of 6” x 9”. It has been set to mirror margins with the inner, top and bottom margins set to 0.75”, the outer margin is set to 0.5” and the gutter to 0.14”.
    It doesn’t matter if I create the PDF from inside Word, or open Acrobat Pro 11.0.9 and click Create From File, while the resulting document size is correct and the odd numbered pages reflect the correct margins, the even numbered pages do not. This results in some text near the outer margin, as well as the page numbers being omitted.
    Does anyone know how to correct this?
    I just noticed that some of the odd numbered pages' text is also cropped. Apparently Acrobat is refusing to set side margins to smaller than 1" (@ 3cm).

    I'm away from my printer, so I'll try it later. Even so, the proposed test is irrelevant. I operate a small publishing house and am trying to upload certain novels to Ingram, the largest book distributor in the world. The specifications I've set are the specifications they've asked for. Since they've said that the results I'm obtaining are unacceptable, and since they demand submission in PDF form, this renders Acrobat Pro for Mac completely unacceptable for anyone in the publication industry. As far as I can tell, Adobe has a serious bug here that it needs to fix—and at once.

  • How to import multiple XML files into one inDesign document without copy/paste ?

    I use InDesign CS6, and I have several XML files with the same structure. Only the data are different.
    I created  an Indesign layout with some tagged placeholder frames on merge mode, for automated layout.
    Today for each XML file I have to create a new InDesign document to import the XML. Everything works fine. Then in order to have all Indesign layouts one after the other into a single Indesign layout, I have to use the copy/paste function.
    I mean for example, copy the contents of all documents to the first one. Or add pages of other documents to the first one, then delete spaces between each page.
    So my question is the following:
    How to repeat this process without copy/paste function, knowing that the
    number of XML files could be unknown.
    Thank you very much for your answer.

    Yes, effectively I would like to catalogue the files into one collection so i can save as one PDF and Print as one.:)
    I know I could save each AI as a pdf them then merge the pdf's together in acrobat, but I have nearly 100 files so would feel more comfortable seeing them all together before print / saving.
    My concern is that if I insert them in Ai, will the file resolution reduce? and will the ai still be editable and would it update the indesign file?
    Thanks for the quick reply

  • How can I save a XML file with JAXP1.1?

    Dear All.
    I write a program to create XML file with DOM model, but I can't know how to save it? My environment is JAXP1.1 and JDK1.3.1,I has been required not use other XML parser toolkits,only JAXP1.1.
    How can I do? thank you.
    Many person give me a idea the com.sun.xml.tree.XmlDocument, but I can't find the class in API document or JAXP1.1's packages. why?
    what is it? How can i use it?
    thank you very much.

    The way to save an XML Document is using a Transformer.
    To have access to a transformer use the packages :
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    Then for saving your Document Object (named dXml) get a Transformer Object with the TransformerFactory Object :
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    Now you have got your Transformer Object, to save your Document Object use the method :
    Document dXml = getMyDocument(); // this is your Document Object.
    OutputStream osSave = getMySaveStream(); // this the OutputStream you need to save your Document.
    try
    t.transform(new DomSource(dXml), new StreamResult(new OutputStreamWriter(osSave)));
    finally
    osSave.close();
    And your Document was now saved.

  • Create xml file with values from context

    Hi experts!
    I am trying to implement a WD application that will have some input fields, the value of those input fields will be used to create an xml file with a certain format and then sent to a certain application.
    Apart from this i want to read an xml file back from the application and then fill some other context nodes with values from the xml file.
    Is there any standard used code to do this??
    If not how can i do this???
    Thanx in advance!!!
    P.S. Points will be rewarded to all usefull answers.
    Edited by: Armin Reichert on Jun 30, 2008 6:12 PM
    Please stop this P.S. nonsense!

    Hi,
    you need to create three util class for that:-
    XMLHandler
    XMLParser
    XMLBuilder
    for example in my XML two tag item will be there e.g. Title and Organizer,and from ur WebDynpro view you need to pass value for the XML tag.
    And u need to call buildXML()function of builder class to generate XML, in that i have passed bean object to get the values of tags. you need to set the value in bean from the view ui context.
    Code for XMLBuilder:-
    Created on Apr 4, 2006
    Author-Anish
    This class is to created for having function for to build XML
    and to get EncodedXML
      and to get formated date
    package com.idb.events.util;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import com.idb.events.Event;
    public class XMLBuilder {
    This attribute represents the XML version
         private static final double VERSION_NUMBER = 1.0;
    This attribute represents the encoding
         private static final String ENCODING_TYPE = "UTF-16";
         /*Begin of Function to buildXML
    return: String
    input: Event
         public String buildXML(Event event) {
              StringBuffer xmlBuilder = new StringBuffer("<?xml version=\"");
              xmlBuilder.append(VERSION_NUMBER);
              xmlBuilder.append("\" encoding=\"");
              xmlBuilder.append(ENCODING_TYPE);
              xmlBuilder.append("\" ?>");
              xmlBuilder.append("<event>");
              xmlBuilder.append(getEncodedXML(event.getTitle(), "title"));
              xmlBuilder.append(getEncodedXML(event.getOrganizer(), "organizer"));
              xmlBuilder.append("</event>");
              return xmlBuilder.toString();
         /End of Function to buildXML/
         /*Begin of Function to get EncodedXML
    return: String
    input: String,String
         public String getEncodedXML(String xmlString, String tag) {
              StringBuffer begin = new StringBuffer("");
              if ((tag != null) || (!tag.equalsIgnoreCase("null"))) {
                   begin.append("<").append(tag).append(">");
                   begin.append("<![CDATA[");
                   begin.append(xmlString).append("]]>").append("</").append(
                        tag).append(
                        ">");
              return begin.toString();
         /End of Function to get EncodedXML/
         /*Begin of Function to get formated date
    return: String
    input: Date
         private final String formatDate(Date inputDateStr) {
              String date;
              try {
                   SimpleDateFormat simpleDateFormat =
                        new SimpleDateFormat("yyyy-MM-dd");
                   date = simpleDateFormat.format(inputDateStr);
              } catch (Exception e) {
                   return "";
              return date;
         /End of Function to get formated date/
    Code for XMLParser:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLParser {
    Enables namespace functionality in parser
         private final boolean isNameSpaceAware = true;
    Enables validation in parser
         private final boolean isValidating = true;
    The SAX parser used to parse the xml
         private SAXParser parser;
    The XML reader used by the SAX parser
         private XMLReader reader;
    This method creates the parser to parse the user details xml.
         private void createParser()
              throws SAXException, ParserConfigurationException {
              // Create a JAXP SAXParserFactory and configure it
              SAXParserFactory saxFactory = SAXParserFactory.newInstance();
              saxFactory.setNamespaceAware(isNameSpaceAware);
              saxFactory.setValidating(isValidating);
              // Create a JAXP SAXParser
              parser = saxFactory.newSAXParser();
              // Get the encapsulated SAX XMLReader
              reader = parser.getXMLReader();
              // Set the ErrorHandler
    This method is used to collect the user details.
         public Event getEvent(
              String newsXML,
              XMLHandler xmlHandler,
              IWDMessageManager mgr)
              throws SAXException, ParserConfigurationException, IOException {
              //create the parser, if not already done
              if (parser == null) {
                   this.createParser();
              //set the parser handler to extract the
              reader.setErrorHandler(xmlHandler);
              reader.setContentHandler(xmlHandler);
              InputSource source =
                   new InputSource(new ByteArrayInputStream(newsXML.getBytes()));
              reader.parse(source);
              //return the results of the parse           
              return xmlHandler.getEvent(mgr);
    Code for XMLHandler:-
    Created on Apr 12, 2006
    Author-Anish
    This is a parser class
    package com.idb.events.util;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.XMLReader;
    import com.idb.events.Event;
    Created on Apr 12, 2006
    Author-Anish
    *This handler class is created to have constant value for variables and function for get events,
        character values for bean variable,
        parsing thr date ......etc
    package com.idb.events.util;
    import java.sql.Timestamp;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Locale;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.helpers.DefaultHandler;
    import java.util.*;
    import com.idb.events.Event;
    import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager;
    public class XMLHandler extends DefaultHandler {
         private static final String TITLE = "title";
         private static final String ORGANIZER = "organizer";
         IWDMessageManager manager;
         private Event events;
         private String tagName;
         public void setManager(IWDMessageManager mgr) {
              manager = mgr;
    This function is created to get events
         public Event getEvent(IWDMessageManager mgr) {
              manager = mgr;
              return this.events;
    This function is created to get character for setting values through event's bean setter method
         public void characters(char[] charArray, int startVal, int length)
              throws SAXException {
              String tagValue = new String(charArray, startVal, length);
              if (TITLE.equals(this.tagName)) {
                   this.events.setTitle(tagValue);
              if (ORGANIZER.equals(this.tagName)) {
                   String orgName = tagValue;
                   try {
                        orgName = getOrgName(orgName);
                   } catch (Exception ex) {
                   this.events.setOrganizer(orgName);
    This function is created to parse boolean.
         private final boolean parseBoolean(String inputBooleanStr) {
              boolean b;
              if (inputBooleanStr.equals("true")) {
                   b = true;
              } else {
                   b = false;
              return b;
    This function is used to call the super constructor.
         public void endElement(String uri, String localName, String qName)
              throws SAXException {
              super.endElement(uri, localName, qName);
         /* (non-Javadoc)
    @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
    This function is used to call the super constructor.
         public void fatalError(SAXParseException e) throws SAXException {
              super.fatalError(e);
    This function is created to set the elements base on the tag name.
         public void startElement(
              String uri,
              String localName,
              String qName,
              Attributes attributes)
              throws SAXException {
              this.tagName = localName;
              if (ROOT.equals(tagName)) {
                   this.events = new Event();
         public static void main(String a[]) {
              String cntry = "Nigeria";
              XMLHandler xml = new XMLHandler();
              ArrayList engList = new ArrayList();
              engList = xml.getCountries();
              ArrayList arList = xml.getArabicCountries();
              int engIndex = engList.indexOf(cntry);
              System.out.println("engIndex  :: " + engIndex);
              String arCntryName = (String) arList.get(engIndex);
              System.out.println(
                   ">>>>>>>>>>>>>>>>>>>>" + xml.getArabicCountryName(cntry));
    Hope that may help you.
    If need any help , you are most welcome.
    Regards,
    Deepak

  • How to parse XML file with namesapce?

    Hi,
       I am trying to parse an xml file having namespace. But no data is returned.
    Sample Code:
    public class XMLFileLoader
    var xml:XML = new XML();
    var myXML:XML = new XML();
    var XML_URL:String = "file:///C:/Documents and Settings/Administrator/Desktop/MyData.xml";
    var myLoader:URLLoader = null;
    public function XMLFileLoader()
    var myXMLURL:URLRequest = new URLRequest(XML_URL);
    myLoader= new URLLoader(myXMLURL);
    myLoader.addEventListener(Event.COMPLETE,download);
    public function download(event:Event):void
    myXML = XML(myLoader.data);
    var ns:Namespace=myXML.namespace("xsi");
    for(var prop:String in myXML)
         trace(prop);
    //Alert.show(myXML..Parameters);
    //trace("Data loadedww."+myXML.toString());
    //Alert.show(myXML.DocumentInfo.attributes()+"test","Message");
    The XML Contains the following format.
    <Network xmlns="http://www.test.com/2005/test/omc/conf"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.test.com/2005/test/omc/conf/TestConfigurationEdition3proposal4.xsd">
        <TestDomain>
          <WAC>
            <!--Release Parameter  -->
            <Parameters ParameterName="ne_release" OutageType="None"
                        accessRight="CreateOnly" isMandatory="true"
                        Planned="false"
                        Reference="true" Working="true">
              <DataType>
                <StringType/>
              </DataType>
              <GUIInfo graphicalName="Release"
                       tabName="All"
                       description="Describes the release version of the managed object"/>
            </Parameters>
    </TestDomain>
    </Network>
    Any sample code how to parse this kind of xml file with namespaces...
    Regards,
    Purushotham

    i have exactly the same problem with KXml2, but using a j2me-polish netbeans project.
    i've tried to work around with similar ways like you, but none of them worked. now i've spent 3 days for solving this problem, i'm a bit disappointed :( what is wrong with setting the downloaded kxml2 jar path in libraries&resources?
    screenshot

Maybe you are looking for

  • Spellcheck not working for Outlook or Word docs

    Hello, I'm having trouble configuring spell check on my MacBook Air. Text is not highlighted when misspelled, for example "updatd" instead of "updated" I have followed path Tools - Spelling and Grammar when finishedI have tried leaving text as is, an

  • 10.6.8 Update & Rosetta

    Hi guys, I've not yet clicked the update button to 10.6.8, but from what I've read here and there I understand Apple will be scrapping Rosetta when Lion comes out. I use a few old apps that need rosetta to run ie; Freehand MX, and wanted to check her

  • Unable to invoke an asynch Oracle BPEL process

    Im currently struggling to invoke an Oracle BPEL web service from another Oracle BPEL process. When creating the invoking process I pasted in the wsdl from the BPEL console to describe the invoked process rather than use the original wsdl generated b

  • Separating form fields

    I'm new to creating forms. I got a PDF doc from someone that I decided to turn into a form so I could fill it out more easily. It has a lot of checkboxes on it so rather than placing them painstakingly one by one I did a lot of copy/paste. It was muc

  • Stored proecedure tutorial for insert, delete, update,select

    I want to integrate the stored procedure in my project i am using jsp, any one suggest me, stored proecedure tutorial for insert, delete, update,select thanx.