Output XML with indentation...

I've not found an answer to this on the forums so was hoping someone might have discovered what's up since...
Using the Transformation API with the default JAXP 1.1 transformer (Xalan) and setting the output property "indent" to "yes", the resulting XML contains carriage returns but no indentation as hoped.
I don't think that indentation is required for the transformer to adhere to the specification but it seems like quite an omission nonetheless.
Does anyone know how to output indented XML without going to the trouble of adding whitespace text nodes into the document tree?
Many thanks,
K.
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(new DOMSource(doc), new StreamResult(out));

We did it this way:
import java.util.Map;
import java.util.HashMap;
import java.util.Properties;
import java.io.*;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.InputSource;
import org.apache.xml.serialize.XMLSerializer;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xerces.parsers.SAXParser;
public class XmlPrettyPrinter extends XMLSerializer {
  private Map mapping = new HashMap();
  public XmlPrettyPrinter(StringWriter out, OutputFormat format) {
    super(out, format);
  public static String beautify(String xml) {
    if (xml == null || xml.trim().length() == 0) {
      return "";
    Reader reader = new StringReader(xml);
    XMLReader parser = new SAXParser();
    try {
      parser.setFeature("http://xml.org/sax/features/validation", false);
      OutputFormat format = new OutputFormat();
      format.setIndenting(true);
      format.setIndent(2);
      format.setLineWidth(80);
      StringWriter out = new StringWriter();
      XmlPrettyPrinter serializer = new XmlPrettyPrinter(out, format);
      parser.setContentHandler(serializer.asContentHandler());
      parser.parse(new InputSource(reader));
      return out.toString();
    } catch (Exception e) {
      // do something about this Exception
    return xml;
  public void characters(char[] chars, int offset, int length) throws SAXException {
    String s = new String(chars, offset, length).trim();
    char[] array = s.toCharArray();
    super.characters(array, 0, array.length);
}Maybe you get an idea what to change in your code.
Regards,
hedtfeld

Similar Messages

  • Output XML with a default namespace using XQuery

    I'm having a problem with namespaces in an XQuery within ALSB.
    We receive XML from a file which doesn't have any namespace and have to transform it into a different structure, giving it a default namespace such as below:
    Input XML
    <inputRoot>
         <inputAccountName>Joe Bloggs</inputAccountName>
         <inputAccountNumber>10938393</inputAccountNumber>
    </inputRoot>
    Desired output XML
    <outputRoot xmlns="http://www.example.org/outputSchema">
         <outputAccounts>
              <outputAccountName>Joe Bloggs</outputAccountName>
              <outputAccountNumber>10938393</outputAccountNumber>
         </outputAccounts>
    </outputRoot>
    When I attempt to do this using XQuery mapper tool, I end up with a namespace prefix on the outputRoot. The XQuery and result follows:
    XQuery
    declare namespace xf = "http://tempuri.org/XQueryProject/scratchTransformations/test/";
    declare namespace ns0 = "http://www.example.org/outputSchema";
    declare function xf:test($inputRoot1 as element(inputRoot))
    as element(ns0:outputRoot) {
    <ns0:outputRoot>
    <outputAccounts>
    <outputAccountName>{ data($inputRoot1/inputAccountName) }</outputAccountName>
    <outputAccountNumber>{ data($inputRoot1/inputAccountNumber) }</outputAccountNumber>
    </outputAccounts>
    </ns0:outputRoot>
    declare variable $inputRoot1 as element(inputRoot) external;
    xf:test($inputRoot1)
    Result
    <ns0:outputRoot xmlns:ns0="http://www.example.org/outputSchema">
         <outputAccounts>
              <outputAccountName>inputAccountName_1</outputAccountName>
              <outputAccountNumber>inputAccountNumber_1</outputAccountNumber>
         </outputAccounts>
    </ns0:outputRoot>
    How can I write the XQuery in such a way thay the namespace prefix isn't output? I've tried many different methods with no success. I can't declare a default element namespace because my input element doesn't have a namespace
    Thanks in advance

    I spoke too soon, it didn't work quite as perfectly as I'd thought :-) It turns out our client can't handle the xml with the namespace prefix but we've worked out the solution to return XML in the format we originally needed.
    Example below:
    XQuery
    declare namespace xf = "http://tempuri.org/XQueryProject/scratchTransformations/test/";
    declare default element namespace "http://www.example.org/outputSchema";
    declare namespace ns1 = ""
    declare function xf:test($inputRoot1 as element(ns1:inputRoot))
    as element(outputRoot) {
    <outputRoot>
    <outputAccounts>
    <outputAccountName>{ data($inputRoot1/inputAccountName) }</outputAccountName>
    <outputAccountNumber>{ data($inputRoot1/inputAccountNumber) }</outputAccountNumber>
    </outputAccounts>
    </outputRoot>
    declare variable $inputRoot1 as element(inputRoot) external;
    xf:test($inputRoot1)

  • Input xml from output xml with reverse transformation

    I have the transformation and the output xml file. Is there any way I get the input message using the trasformation and output message with minor manual changes? Is there any tool for that?

    Hi Ragavalli,
    I understand that you want to archive the incoming message before map is applied. (Assuming map is not to be there on send port as not very clear about restrictions you have)
    There are two ways:
    1. Use of Custom pipeline component to archive message . You can find one at :http://biztalkarchiving.codeplex.com/
    2. The other option is to have
     Recieve port without map
     Two send port one  pointing to Archive folder  and other to temporary folder (intermediate)location
     Add both the send port to Send Port group. Have filter on it as BTS.PortName = ReceivePortName
     Create a receive port with temporary folder as receive location 
     Apply the inbound map on this port
    If map can be allowed on send port then
    1. Rec port without map
    2. Two send port, one without map other with map. 
    Thus original message will be saved by Send Port 1 and transformed by Send Port 2
    Maheshkumar
    S Tiwari|User
    Page|Blog|BizTalk
    Server : Scheduling Orchestration using Trigger Message

  • Displaying xml with indent

    Hi, was wondering if there was a way to present an xml string such as
    "<?xml version='1.0' encoding='ISO-8859-1'?><hl7:QueryByParameter xmlns:hl7='urn:hl7-org:v3' ><hl7:statusCode code='new'/></hl7:QueryByParameter>";
    "properly" with indents of say 2 spaces for each child element of the root element like ..
    <?xml version='1.0' encoding='ISO-8859-1'?>
    <hl7:QueryByParameter xmlns:hl7='urn:hl7-org:v3' >
    <hl7:statusCode code='new'/>
    </hl7:QueryByParameter>
    i dont mind if it is transformed into html and looks like that or if the actual xml string is changed to have spaces in it. any helps greatly appreciated

    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    transformer.transform(new DOMSource(doc), new StreamResult(out));

  • Create XMl with indentation by DOM

    Hi all,
    I wanna create a xml file with indentation.
    e.g
    <MyXML>
         <MyNode attr1="value1"/>
         <MyNode2 attr1 = "value1"/>
    </myXML>
    I save my xml with the following code
         TransformerFactory transFactory = TransformerFactory.newInstance();
         Transformer transformer = transFactory.newTransformer();
         DOMSource source = new DOMSource(getDocument());
         FileOutputStream os = new FileOutputStream(file);
         StreamResult result = new StreamResult(os);
         transformer.transform(source, result);it create a result like:
    <MyXML><MyNode attr1="value1"/><MyNode2 attr1 = "value1"/></myXML>
    how to achieve my purpose ?

    sorry again, this is what i really want to achieve
    <MyXML>
         <MyNode attr1="value1"/>
         <MyNode2 attr1 = "value1">
              <MyChildNode attr="value"/>
         </MyNode2>
    </MyXML>

  • Proxy output not displayed in the output XML

    Hi,
    I have created a web service and is calling the service using SOAP UI tool. To do it i have created an RFC Fm and inported to SAP PI and activated it with the input and output parameters that i need. When i am calling the service through the SOAP UI, in debugging( in the provider class of the service interface of the sproxy transaction ) i am able to see the values filled in one of the parameters but the same is not getting displayed in the output XML.(Response). Can any one please suggest what cud be the reason.
    Thanks

    Hi,
    can give us a hint? Code output, screenshot? btw I hope your service is a Synchronous service.
    Thanks Nick.

  • How to use an .xsl file to transform input XML to re-formatted output XML?

    Hello,
    I have a .xml file from a report that I want to use a stylesheet to transform into a different .xml format.
    I am reading that I can create a .xsl file to read my input and then transform it to a new output .xml file.
    How do I load this into the Apps?
    I tried creating a template definition and loading the .xsl in as type 'XSL-TEXT' and also, I added
    <?xml-stylesheet type="text/xsl" href="Transform.xsl"?> to my xml data source. The output looked the same as the input.
    Has anyone done this before? Any suggestions would be great!
    Thanks
    -CC

    This is how I use e4x with HTTPService:
    import mx.collections.XMLListCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable] private var claimsXLC:XMLListCollection;
    private function claimsHandler(evt:ResultEvent):void{
        claimsXLC = new XMLListCollection(evt.result..claim as XMLList);
    XML data is being returned, but I use XMLList to create the XMLListCollection.
    If this post answers your question or helps, please mark it as such.

  • Outputting XML carriage return in HTML via XSLT

    Hi,
    I have a scenario where I execute a View Object query in ADF to retrieve results from a particular table in the Database. I then iterate through the results in my Java managed bean and manually construct an XML file with all the appropriate tags. I then pass the XML file through a Transformer class in the Java bean based on an XSLT I have created to produce an HTML page. However I have an issue when it comes to handling carriage returns. One of the database table columns can contain carriage returns within its value but in the final HTML page the carriage returns don't have any effect and the text just displays on one line.
    In the database, the values are stored with the carriage return and in SQL Developer, Toad etc this can be seen e.g. Text1 Text2 Text3 Text4 will display on separate lines. In the XML, the carriage return seems to still be there as when I open the file my element which contains the carriage returns shows each part on a new line e.g. <textElement>Text1
                                                           Text2
                                                           Text3
                                                           Text4</textElement>     (The Text2, Text3 and Text4 all start on a new line at the beginning and there's no prior white space as shown in this post)
    The XML file in JDeveloper also shows carriage return arrow symbols where there is one.
    The HTML page just shows them as Text1 Text2 Text3 Text4 all on one line. Inspecting the source of the HTML shows that the carriage return is in fact there as it also displays as per the XML with the values on separate lines.
    Outputting the value from the View Object in Java to the log shows the value coming out like this - Text1 Text2Text3Text4, which is strange but I know the carriage returns are there so I'm not too fussed about this.
    I have tried escaping the characters in the Java by doing str.replaceAll("[\\r\\n]", ""); (but replacing the "" with &#xD; &#xA; or &x0A;) so in the XML it replaces carriage returns and line feeds with these escaped characters. However, when the XSLT parses the XML it doesn't pick these up and instead actually outputs these actual characters as they are e.g. Text1&x0A;Text2&x0A;Text3&x0A;Text4
    So I can confirm that the carriage return is carrying all the way through to the XSL but I can't help but think that maybe I need to do something in the XSL to process this somehow, e.g. doing the equivalent of the 'replace' in Java but I don't know what I need to search for in the XML and also what to actually replace it with..Do I just replace it with a </BR> in HTML?
    We also parse the XML using PDF and Excel XSL Transformer class and see the same results.
    Any help would be appreciated.
    Thanks

    That's a very commonly asked question.
    HTML doesn't preserve linefeeds, except for the <pre> tag.
    You'll have to replace those characters with <BR/> tags in the XSLT.
    Search the Internet for terms like "XSLT HTML LF", you'll find some XSLT sample templates to handle the replacement.

  • Mapping question - how to remove empty recordsets from output XML?

    Hello everyone!
    I have a mapping problem I hope you can help me out with.
    Here is an example of the source message:
    <IDOC>
    .    <HEAD>
    .    </HEAD>
    .    <DET>
    .    .    <Node>
    .    .    .    <nodeA>001</nodeA>
    .    .    .    <nodeB>OA</nodeB>
    .    .    </Node>
    .    .    <Node>
    .    .    .    <nodeB>OB</nodeB>
    .    .    </Node>
    .    .    <Node>
    .    .    .    <nodeA>002</nodeA>
    .    .    .    <nodeB>OC</nodeB>
    .    .    </Node>
    .    </DET>
    </IDOC>
    After testing the above XML in the message mapping, here's what my target looks like:
    <FILE>
    .    .    <Rec>
    .    .    .    <nA>001</nA>
    .    .    .    <nB>OA</nB>
    .    .    </Rec>
    .    .    <Rec>
    .    .    .    <nB>
    .    .    .    <nA>
    .    .    </Rec>
    .    .    <Rec>
    .    .    .    <nA>002</nA>
    .    .    .    <nB>OC</nB>
    .    .    </Rec>
    </FILE>
    "Node" in the "source" message is mapped to "Rec" in my "target" message.
    "Node=" -
    > "Rec"
    You may notice the the "Rec" in the second entry has empty fields. The reason this is so is because I put an "IF" condition in field "nA" and field "nB" that checks whether "nodeA" in the "source" exists/has a value, and if it doesn't, empty values should be given.
    Here's my problem, I need the XML output to be clean. All empty Recs should be removed from the Output XML so that it resembles the one below:
    <FILE>
    .    .    <Rec>
    .    .    .    <nA>001</nA>
    .    .    .    <nB>OA</nB>
    .    .    </Rec>
    .    .    <Rec>
    .    .    .    <nA>002</nA>
    .    .    .    <nB>OC</nB>
    .    .    </Rec>
    </FILE>
    I've tried several ways to get this done to no avail. Would anyone be able to help me out? I would really, really appreciate it!
    Warm regards,
    Glenn

    Hello,
    Here's how the Display Queue looks like from the "CreateIF"
    Default Context:
    0     [false]     [suppress]
    1     [false]     [suppress]
    2     [false]     [suppress]
    3     [true]     []
    4     [false]     [suppress]
    5     [true]     []
    6     [false]     [suppress]
    7     [false]     [suppress]
    8     [false]     [suppress]
    9     [true]     []
    10     [false]     [suppress]
    11     [false]     [suppress]
    12     [false]     [suppress]
    13     [true]     []
    14     [false]     [suppress]
    15     [false]     [suppress]
    16     [false]     [suppress]
    17     [true]     []
    18     [false]     [suppress]
    19     [false]     [suppress]
    20     [false]     [suppress]
    21     [true]     []
    CreateIF Context up one notch:
    0     [false]     [suppress]
    1     [true]     []
    2     [true]     []
    3     [true]     []
    4     [true]     []
    5     [true]     []
    6      [true]     []     
    7     [true]     []
    8     [false]     [suppress]
    9     [false]     [suppress]
    10     [false]     [suppress]
    11     [false]     [suppress]
    Here's how the Display Queue looks like from the "NodeA"
    SUPPRESS     [false]
    SUPPRESS     [false]
    [0000000292]     [false]
    [0000000292]     [true]
    [0000000252]     [false]
    [0000000252]     [true]
    SUPPRESS     [false]
    [0000000078]     [false]
    [0000000078]     [false]
    SUPPRESS     [true]
    [0000000109]     [false]
    [0000000109]     [false]
    SUPPRESS     [false]
    [0000000292]     [true]
    [0000000292]     [false]
    SUPPRESS     [false]
    [0000000076]     [false]
    [0000000076]     [true]
    SUPPRESS     [false]
    [0000000292]     [false]
    [0000000292]     [false]
    SUPPRESS     [true]
    SUPPRESS     [false]
    NodeA context one notch up:
    SUPPRESS     [false]
    [0000000292]     [true]
    [0000000252]     [true]
    [0000000078]     [true]
    [0000000109]     [true]
    [0000000292]     [true]
    [0000000076]     [true]
    [0000000292]     [true]
    [0000000074]     [true]
    [0000000077]     [true]
    [0000000081]     [true]
    [0000000292]     [true]
    [0000000252]     [true]
    [0000000081]     [true]
    [0000000081]     [false]
    SUPPRESS
    Hope that helps you help me!
    Glenn

  • Idoc to XML, namespace is not getting created in output XML

    Hi All
    My interface is idoc to XML.
    I am using graphical message mapping.
    In output xml , namespace is not  formed
    Can any one tell why namespace is not  created in the XML and
    How to add the  namespace to the  output XML .
    Kindly help
    Regards,
    Sheela

    Hi,
    You can change your external definition to achieve it.  just compare the structure of your xsd with some other normal data type xsd and change accordingly.
    Inder

  • Error in outputting xml formatted data

    Hello,
    I'm trying to output xml formatted data using apex.
    At about 70% into the formatted output I get this in the browser:
      <descript>punct= & > < /,() &</descript>
      </row>
    - <row The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Only one top level element is allowed in an XML document. Error processing resource 'http://apex.oracle.com/pls/otn/f?p=158...
    <script language="JavaScript1.1" type="text/javascript">
    -^
    m">>
    <DIVI have a 600 row table (dml below) with identical string in each row of the descript column. (I put in some special characters just to push it through the escape function for html. It is displaying the text correctly.)
    The page has one report region (plsql below).
    The page template is stripped down.
    My local results are identical to the otn hosted workspace.
    I did dump the table in xml format and displayed the dump file in browser without a problem, so I'm missing something in the code.
    Thank you.
    Albert
    On OTN webspace, go to http://apex.oracle.com/pls/otn/f?p=15866:1:1291425545573680200:::::
    plsql
    declare
    xdescript varchar2(4000);
        begin
        -- xml preface is in the page template
        -- htp.p('<?xml version="1.0"?>');
        htp.p('<rowset>');
        begin
            for item in
            (select descript,cid from receipts order by cid)
            loop
            htp.p ('<row>');
            xdescript := htf.escape_sc(item.descript);
            htp.p('<cid>' || item.cid || '</cid>');
            htp.p('<descript>'|| xdescript || '</descript>');
            htp.p('</row>');
            end loop;
        end;
        htp.p ('</rowset>');
    end;
    dml
    CREATE TABLE  "RECEIPTS"
       (     "CID" NUMBER,
         "AMOUNT" NUMBER NOT NULL ENABLE,
         "CLEARED" DATE,
         "DESCRIPT" VARCHAR2(80),
         "DATEENTERED" DATE DEFAULT SYSTIMESTAMP,
         "CHECKNBR" NUMBER,
         "CLEARSEQ" NUMBER DEFAULT 0,
          CONSTRAINT "RECEIPTS_PK" PRIMARY KEY ("CID") ENABLE
    CREATE SEQUENCE   "RECEIPTS_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999
    INCREMENT BY 1 START WITH 4319 CACHE 20 NOORDER  NOCYCLE
    CREATE OR REPLACE TRIGGER  "BI_RECEIPTS"
      BEFORE INSERT ON "RECEIPTS"
      FOR EACH ROW
    BEGIN
        SELECT "RECEIPTS_SEQ".NEXTVAL INTO :NEW.CID FROM DUAL;
    END;
    ALTER TRIGGER  "BI_RECEIPTS" ENABLE
    /

    May be it helps you. I use SQL/XML and APEX Application Process to generate XML succesfully
    Here is the result:
    http://htmldb.oracle.com/pls/otn/f?p=9774:101:0:APPLICATION_PROCESS=RSSNEWEVENTS
    and here is the Process Text source:
    declare
    a clob;
    begin
    owa_util.mime_header( ccontent_type => 'text/xml', bclose_header => TRUE, ccharset => 'utf-8');
    htp.prn('<?xml version="1.0" encoding="UTF-8"?>');
    select
    XMLTYPE.getStringVal(
    XMLElement("rss",
    XMLAttributes('2.0' as version),
    XMLElement("channel",
    XMLConcat(
    XMLElement("title",'iActiveLife - novinky'),
    XMLElement("link",'http://www.iactivelife.cz/'),
    XMLElement("description",'iActiveLife - Zajímavý život snadn&#283;ji'),
    XMLElement("language",'cs'),
    XMLElement("pubdate",''),
    XMLAgg(
    XMLElement("item",
    XMLConcat(
    XMLElement("title",event_name),
    XMLElement("link",'http://htmldb.oracle.com/pls/otn/f?p=' || v('APP_ID') || ':37:' || v('SESSION') || '::NO::P37_EVENT_ID:' || event_id),
    XMLElement("description",'')
    ) into a
    from (
    select event_id,event_name,issue_date, last_update_order
    from (
    select events.event_id, events.event_name, events.issue_date, rank () over (order by events.issue_date desc) as last_update_order
    from events
    where exists ( select * from opportunities where events.event_id=opportunities.event_id and opportunities.user_id is not null)
    order by events.issue_date desc)
    where last_update_order<=10
    htp.prn(a);
    end;

  • 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);
    }

  • Output XML file problem (in FILE to RFC scenario)

    hi,
       my problem is that in the export parameter i have 3 variables but my output xml file shows only 2 parameters . I have checked my mapping all 3 parameters are mapped properly in output mapping .
    Initially when i started the scenario there were only 2 parameters in my export list .
    i completed this suuccesfully and then as per new requirement one more parameter was needed to be added i added a new parameter and reimported my rfc .
    the response tab of the reimported RFC shows me the newly added parameter but my final xml file only shows me the previous 2 it doesnt show me the newly added one is there any seeting which i need to change like in idoc where we have to readd the idoc in IDX2
    With regards
    Bhawarlal Choudhary

    Hi,
    2 Introduction
    Configuring IDoc adapter in Exchange Infrastructure 3.0 requires some configuration on the SAP
    systems, for both XI and the backend system where the IDoc message is to be sent. These steps, although
    simple, are many times missed or mis-configured, causing the delivery of messages to fail.
    Since IDoc adapter uses the ABAP stack, instead of J2EE, the configuration requirements are mainly in
    ABAP.
    Setting up IDoc adapters requires the XI integration server to be able to communicate with the backend
    SAP system, and also to make sure that the Logical System Name used when posting IDoc exists on the
    backend SAP system.
    3 The Step By Step Solution
    The basic steps for the IDoc configuration are outline below:
    1. Configure SM59 on XI to communicate to SAP backend system.
    2. Configure port on XI for IDoc communication.
    3. Create or verify the Logical System Name on the SAP backend system.
    4. Create or verify business system in XI’s System Landscape Directory.
    5. Verify the Logical System Name of the business system.
    6. Verify or add the Logical System Name for the sender business system.
    7. Create/configure the Communication Channel for the IDoc receiver adapter
    3.1 Configure SM59 on XI to communicate to SAP backend system.
    1. Using transaction SM59, create an RFC destination with Connection Type = “3”.
    In this example, the RFC destination name is “NDVCLNT510”.
    2. Enter the logon information:
    3. Test the connection by clicking on “Testing connection” and “Remote logon”.
    Both must be successful.
    3.2 Configure port on XI for IDoc communication.
    4. Go to transaction IDX1 on XI, and create a port. In this example, the Port name is “SAPNDV”.
    •     &#61472;The Port name must be in the form of “SAPxxx”, where xxx is the system ID of the backend SAP
    system.
    •     The Client must be the client number of the backend SAP system.
    •     Select the RFC Destination which was created in the previous step.
    3.3 Create or verify the Logical System Name on the SAP backend system.
    5. Enter transaction SALE on the SAP backend system.
    6. Create or verify the Logical System Name. In our example, NDVCLNT510 is verified.
    3.4 Create or verify business system in XI’s System Landscape Directory.
    The business system name for the SAP backend system must contain a valid Logical System Name. This Logical System Name is the one verified or created in the previous step.
    7. In the System Landscape Directory,  select the SAP backend business system. If one does not exist, then create the business system. Verify the Logical  System Name.
    3.5 Verify the Logical System Name of the business system.
    8. In the Integration Directory, doubleclick on the business system (in our example, it is NDVCLNT510).
    Navigate the menu:
    Service • Adapter Specific Identifiers.
    If information is empty or incorrect, then it will have to be synchronized with the content of the System Landscape Directory. Follow the steps below for synchronization.
    9. (Optional) Synchronization of the business system in Integration Directory to the business system in System
    Landscape Directory.
    •     &#61472;Double-click on the business system in the Integration Directory.
    •     &#61472;Switch to Edit mode.
    •     &#61472;Select menu: Service • Adapter-Specific Identifiers 
    10. (Optional) Within the dialog box, click on the button as indicated below to resynchronize.
    11. (Optional) If the expected data from the System Landscape Directory is not updated, then the SLD cache may need to be cleared first.
    3.7 Create/configure the Communication Channel for the IDoc receiver adapter.
    15. In the Integration Directory, create an IDoc receiver communication channel.
    •     &#61472;The RFC Destination is from step 3.1.
    •     &#61472;The Port is from step 3.2.
    NOTE:
    There is no need to create an IDoc sender Communication Channel for XI. Instead, the backend SAP system must be configure to send the IDoc to XI.
    4 Appendix
    Transaction: IDX2
    There are a couple of situation where IDX2 can be useful on the XI system.
    1. When we want to test connection between the XI and SAP backend system.
    2. When an IDoc has changed, and the meta data stored in XI needs to be update. When an IDoc is sent from the SAP backend system to XI, XI will first check to see if the meta data for the IDoc is already in its persistent cache. If not, then XI will use the configuration in IDX1 to retrieve the IDoc meta data from the backend system. If the
    meta is already in cache, then it will NOT do so. Therefore, when an IDoc has changed, it is necessary to manually update the new meta data on XI, or delete it from the cache, so that the latest version can be retrieved. IDX2 is used for this purpose.
    Go to transaction IDX2 and click on “Create”.
    Enter the IDoc Type and the Source Port as defined in step #2. Click “Continue”.If successful, the following will show up. If error occurs, then the IDX1 configurations will need to be re-checked.
    Regards
    Hemant
    If find helpful plz award points

  • Special characters issue in output XML - file adapter  - SOA 10.1.3.4

    Hi,
    I use a DB adapter and File adapter to retreive data from database and create output XML file.
    For the database record which have special characters (for example ' , <, >), it will just output the same character in XML file, which cause other system to reject this XML file because of those characters.
    Anyone have this issue ? How can i resolve that ?
    Thanks

    Try converting the characters to &lt; and &gt;. This should work. Make sure the stand-alone & character is converted to & amp; (written with space as HTML will convert it back to &).
    -AR

  • Transform the xml with ' and "

    HI,
    i am converting from one xml to anther xml using XSLT, in my output xml file &apos; values are replacing with ' symbols. i want &apos; values in my output xml file.
    my input xml file is
    <?xml version="1.0" encoding="UTF-8"?>
    <ARTICLE>
    <TITLE>A Sample Article123456&apos;123456&apos;</TITLE></ARTICLE>
    my xslt file is
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml"/>
    <xsl:template match="/">
    <Message>
    <xsl:apply-templates/>
    </Message>
    </xsl:template>
    <xsl:template match="/ARTICLE/TITLE">
    <Sample><xsl:value-of select="/ARTICLE/TITLE" />
    </Sample>
    </xsl:template>
    </xsl:stylesheet>
    my java source code
    public class MessageGeneration
    public static void main(String []a)throws Exception
    Reader xmlSourceReader;
    Writer xmlResultWriter;
    xmlSourceReader = new InputStreamReader(new FileInputStream(
    "src/xml/message.xml"), "UTF-8");
    xmlResultWriter = new OutputStreamWriter(new FileOutputStream(
    "src/xml/outMessage.xml"), "UTF-8");
    TransformerFactory tranFactory = TransformerFactory.newInstance();
    Transformer transformer = tranFactory.newTransformer(source);
    StreamSource xmlSource1 = new StreamSource(xmlSourceReader);
    StreamResult xmlResult1 = new StreamResult(xmlResultWriter);
    transformer.transform(xmlSource1, xmlResult1);
    how can i get &apos; symbols in my out file.
    Thanks
    Dattu

    It isn't necessary to escape the apostrophes and quotes in the example you showed, although it isn't wrong to escape them either. Both are well-formed XML and they are equivalent. So that means you don't need to ask for them to be escaped, and therefore the XML philosophy implies you aren't allowed to ask for them to be escaped. Is there a particular reason you have to have them escaped?

Maybe you are looking for

  • Word docs

    Hi all, How to open word docs and excel sheets in OEL5? Thanks, Chandu

  • Cannot find config.js file in user folder

    Dear All, I could not find config.js in user java script folder. I used  app.getPath("user", "javascript"); function to find the user folder and it contains glob.js and glob.settings.js file. Where should i find Config.js file to execute priviledged

  • Initial AP rollout on 5508 HA-SKU and N+1 redundancy

    Hi Board, I have a 7.4 WLC pair - one as primary and one as secondary WLC. They are not doing AP-SSO. I'm aware of all the design and configuration guides, but there are still some questions. Primary WLC: 50 AP count / Secondary WLC: 500 AP count (du

  • Problems with the time setting. help please

    i have the time set on my ipod touch by the city i live. the time will be right for a couple days, but then it becomes an hour behind. how does that happen or how can i make that not happen? can anyone please help me?

  • E-Recruitment  - Business Partner Integration

    Where can i find Activate Integration node, to integrate E-Recruiting - Business Partner... •        Switch PBPHR: ON •        Switch HRAC: X <b>Thanks & Regards, Raghu</b>