Splitting XML Files without namespaces

Hello,
I have a file that looks similar to this:
<?xml version="1.0" encoding="UTF-8"?>
<File>
 <Header>
  <Location>Phoenix</Location>
  <Date>052214</Date>  
 </Header>  
 <Bill></Bill>
 <Trailer>
  <Total>1076</Total>
 </Trailer>
</File>
What I would like to do is split the file (<Bill> is repeating) and I understand I should be able to do this with an envelope schema. I've done some research and every example I'm coming across happens to have a namespace in the sample schema.
How can I accomplish the same thing without the namespace?
Do I need to add the namespace using the ESB Toolkit, and if so, am I supposed to add a namespace to the repeating element? I looked into that solution and couldn't understand how to add a namespace to the Bill element, only the root. Unfortunately I trashed
that approach and went with an orchestration. While that is working, it just doesn't seem right if I can accomplish this task in the receive stage.
Any help/encouragement would be appreciated.

The problem is that if you split the message on an element that has no namespace, you will need a Schema without namespace (in your case with a root element of "Bill" and no namespace).
Having Schemas without namespaces in BizTalk is bad practice and should, in general and if possible, be avoided.
So what I would do is create a custom Pipeline Component that (either using XDocument, XMLDocument or Regular Expression) appends a namespace to all "Bill" elements and also a namespace to the Root. 
Apply the Component in the Decode Stage on your Receive Pipeline so that it is applied BEFORE the disassemble stage, and then create your "Bill" Schema with the newly appended Namespace, and also Apply the Batch namespace to your Envelope Schema.
An Example:
<?xml version="1.0" encoding="UTF-8"?>
<b:File xmlns:b="http://Batch">
<Header>
<Location>Phoenix</Location>
<Date>052214</Date>
</Header>
<c:Bill xmlns:c="http://namespace"></c:Bill>
<c:Bill xmlns:c="http://namespace"></c:Bill>
<c:Bill xmlns:c="http://namespace"></c:Bill>
<c:Bill xmlns:c="http://namespace"></c:Bill>
<Trailer>
<Total>1076</Total>
</Trailer>
</b:File>
Morten la Cour

Similar Messages

  • Xml file without namespace with file adapter

    Hi,
    Please can you assist. We will be receiving a XML file from an application without the namespace in the file.
    As I tested thusfar PI requires a namespace as part of the xml file.
    How would it be possible to you handle this with the file adapter.
    Ex.
    <?xml version="1.0" encoding="UTF-8"?>
    <applicatrion>
         <orders>
              <order>
                   <action>I</action>
                   <orderId>4261A92485</orderId>
              </order>
         </orders>
    </application>
    Regards
    Willie Hugo

    Hi Hugo,
    Please see if this link could clear some doubts http://www.w3schools.com/XML/xml_namespaces.asp
    We generally get an idoc xml in the below format without any issues:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <ORDERS05>
    - <IDOC BEGIN="1">
    - <EDI_DC40 SEGMENT="1">
      <TABNAM>EDI_DC40</TABNAM>
      <MANDT>510</MANDT>
      <DOCNUM>0000000000127051</DOCNUM>
      <DOCREL>700</DOCREL>
      <DIRECT>1</DIRECT>
      <IDOCTYP>ORDERS05</IDOCTYP>
      </EDI_DC40>
    Thanks,
    Sudhansu

  • How must getElementsByTagName work on an xml file with namespaces?

    Hello together,
    is there any normative document, which specifies
    which nodes must be returned by
    the org.w3c.dom.Document method
    getElementsByTagName when which was
    created by a namespace aware dom parser
    from an xml file containing namespaces?
    In other words:
    when you have an xml file:
    <someprefix:somenode xmlns:someprefix="http://someuri">
    <someprefix:innertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    <someprefix:mostinnertag>
    </someprefix:mostinnertag>
    </someprefix:innertag>
    </someprefix>
    and you call
    document.getElementsByTagName( ... );
    1) How many nodes must be returned when giving
    "mostinnertag" as parameter?
    2) How many nodes when giving "someprefix:mostinnertag" as parameter?
    Is it allowed to use the "non namespaceaware"
    method and not "getElementsByTagNameNS"?
    I know:
    a) xerces returns 2 nodes when using
    alternative 2 and none with alternative 1
    b) oracle xml parser returns 2 nodes when using
    alternative 1 and none when using alternative 2
    Which implementation is right?
    Yours
    Stefan

    I've got some problems with this methos and xerces too.
    Perhaps the two implementations (xerces and oracle) are different. I mean xerces implementation gives you nodes of this name but without namespace and oracles's implementation gives you modes with namespace whose unprefix-name is "mostinnertag".

  • Reload web-inf/web.xml file without restarting tomcat

    Please help me if any one have a solution .
    I am doing development in jsp, servlet. I am using tomcat5 as a webserver.
    i want to reload web-inf/web.xml file without restarting tomcat.

    From the tomcat admin page you can stop/start and refresh individual applications. See the tomcat documentation. Which, when you have a question about tomcat, you should always do first.

  • I am wondering if there is a way to validate XML file without using .......

    I am wondering if there is a way to validate XML file without using the <!DOCTYPE... but pass in the location of the schema/DTD file as a parameter to a validating method?
    thanks

    None that I know of. The only thing close is to use the EntityResolver interface where you can modify the location of the DTD file before it's being loaded and parsed, but that requires a <!DOCTYPE ...> in the XML file.
    Good luck.

  • Upload of Customs Duty Rates (xml file) without transport request creation

    Hi All
    Can we upload the Customs Duty Rates (xml file) without transport request directly in the system.
    Thanks & Best Regards
    Kiran

    Hi Kiran,
    Please check transaction & program /SAPSLL/TLC_CUSB_UPL in GTS.
    This allows you to upload the XML from a local source or an application server path.
    I do not think a transport request is required in this scenario.
    Best Regards,
    Eoin

  • 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

  • XI have to break/split XML-File into N times a XML Message

    Hello,
    Can anyone help with this one. I guess this is not an easy exercise but I need to solve it urgently.
    XI gets a XML-file from a system.
    This file has N times a element <XBT>.
    Every time XI gets such a file the number of <XBT> is different.
    XI haves to break this xml into N xml messages according to element ><XBT> in order to send them to Sap sequentially.
    For example the following XML file have to split up into 2 xml files (the elements XBT occurs 2 times)
    How can this be done?
    <mt_BubaBestand>
    <b><XBT></b>
      <Algemeen>
         <Verkooporganisatie>5000</Verkooporganisatie>
         <Distributiekanaal>50</Distributiekanaal>
         <Productgroep>50</Productgroep>
         <Ordernummer>123123</Ordernummer>
         <Verkoopgroep/>
         <Documentdatum>20061207</Documentdatum>
         <Medewerker_nr>e60217</Medewerker_nr>
         <Medewerker_naam>Hermans</Medewerker_naam>
         <CRM_nr/>
         <CIFDedicated/>
         <Klantgroep/>
      </Algemeen>
    <b></XBT></b>
    <b><XBT></b>
      <Algemeen>
         <Verkooporganisatie>5000</Verkooporganisatie>
         <Distributiekanaal>50</Distributiekanaal>
         <Productgroep>50</Productgroep>
         <Ordernummer>123123</Ordernummer>
         <Verkoopgroep/>
         <Documentdatum>20061207</Documentdatum>
         <Medewerker_nr>e60217</Medewerker_nr>
         <Medewerker_naam>Hermans</Medewerker_naam>
         <CRM_nr/>
         <CIFDedicated/>
         <Klantgroep/>
      </Algemeen>
    <b></XBT></b>
    </mt_BubaBestand>

    This is pretty standard procedure if you are posting these messages to R/3.  As was pointed out in the weblogs above, when using IDocs you don't need to do any tricky configuration.  Just make sure that your XML structure is set correctly (ie:  1 to unbounded, etc) to the limits that you want, and XI will automatically loop the mapping process for each instance of the <XBT> item that it detects in the source message.  You mentioned:
    <i>For example the following XML file have to split up into 2 xml files (the elements XBT occurs 2 times)</i>
    Well, you don't actually split it into two XML files per say, XI just processes the source message straight to multiple IDocs using the IDoc adapter.

  • SAP PI 7.1. Splitting XMl file after 998 rows.

    I need to split the XML file for FI interface after 998 rows. How I can use File content conversion with XML file at sender adapter?
    Please suggest me a solution.

    Hi Nirman,
    If it is an XML file then you need to handle that in mapping. Below is the sample code.
    int count  = 0;
    int count1  = 0;
    for(int j = 0; j< a.length; j++)
         count  = count + 1;
         count1 = count1+ 1;
         result.addValue(a[j]);
         if (count == 998)
    //     if (count == var998)
              if (a.length - count1==0)
                        count = 0;
              else
                        result.addContextChange();
                        count = 0;

  • C# Split xml file into multiple files

    Below i have an xml file, in this file, i need to split this xml file into multiple xml files based on date column value,
    suppose i have 10 records with 3 different dates then all unique date records should go into each file . for ex here i have a file with three dates my output should get 3 files while each file containing all records of unique date data. I didn't get any idea
    to proceed on this, thats the reason am not posting any code.Needed urgently please
    <XML>
    <rootNode>
    <childnode>
    <date>2012-12-01</date>
    <name>SSS</name>
    </childnode>
    <childnode>
    <date>2012-12-01</date>
    <name>SSS</name>
    </childnode>
    <childnode>
    <date>2012-12-02</date>
    <name>SSS</name>
    </childnode>
    <childnode>
    <date>2012-12-03</date>
    <name>SSS</name>
    </childnode>
    </rootNode>
    </XML>

    Here is full code:
    using System.Xml.Linq;
    class curEntity
    public DateTime Date;
    public string Name;
    public curEntity(DateTime _Date, string _Name)
    Date = _Date;
    Name = _Name;
    static void Main(string[] args)
    XElement xmlTree = new XElement("XML",
    new XElement("rootNode",
    new XElement("childnode",
    new XElement("date"),
    new XElement("name")
    string InfilePath = @"C:\temp\1.xml";
    string OutFilePath = @"C:\temp\1_";
    XDocument xmlDoc = XDocument.Load(InfilePath);
    List<curEntity> lst = xmlDoc.Element("XML").Element("rootNode").Elements("childnode")
    .Select(element => new curEntity(Convert.ToDateTime(element.Element("date").Value), element.Element("name").Value))
    .ToList();
    var unique = lst.GroupBy(i => i.Date).Select(i => i.Key);
    foreach (DateTime dt in unique)
    List<curEntity> CurEntities = lst.FindAll(x => x.Date == dt);
    XElement outXML = new XElement("XML",
    new XElement("rootNode")
    foreach(curEntity ce in CurEntities)
    outXML.Element("rootNode").Add(new XElement("childnode",
    new XElement("date", ce.Date.ToString("yyyy-MM-dd")),
    new XElement("name", ce.Name)
    outXML.Save(OutFilePath + dt.ToString("yyyy-MM-dd") + ".xml");
    Console.WriteLine("Done");
    Console.ReadKey();

  • Include attachments in a xml file without using mail adapter

    Hello Experts,
    Is there a way to include attachments like pdf or excel in a xml file?
    It is a file to file scenario in which i have to include the attachment in the output file.
    Thanks and regards,
    Merrilly

    Hi,
    Check this links,
    PDF
    SAP Network Blog: XI: Read data from PDF file in Sender Adapter
    /people/sap.user72/blog/2005/07/31/xi-read-data-from-pdf-file-in-sender-adapter
    SAP Network Blog: XI: Generate PDF file out of file adapter
    /people/sap.user72/blog/2005/07/27/xi-generate-pdf-file-out-of-file-adapter
    EXCEL FILES
    SAP Network Blog: XI: Generating Excel files without the Java nor the Conversion agent not possible?
    /people/michal.krawczyk2/blog/2005/12/10/xi-generating-excel-files-without-the-java-nor-the-conversion-agent-not-possible
    SAP Network Blog: Read Excel instead of XML through FileAdapter
    /people/sap.user72/blog/2005/07/04/read-excel-instead-of-xml-through-fileadapter
    Regards,
    Phani
    Reward points if Helpful

  • How to include xml file without embedding in flex web application?

    Hi
    I have a big XML file around 11 mb. I want to include this xml in my web application without embedding.
    So anyone have idea to include.
    Please suggest me any idea.
    Thanks

    If you don't want to embed the XML file into a SWF, then the SWF can download the XML file from the server at runtime when it needs it. But there will be a delay while that happens. Maybe it would be better to put the data in the XML file into a database and then access only the parts of it that you need.
    Gordon Smith
    Adobe Flex SDK Team

  • Split XML File

    I have a large xml file which i would like to split based on name of element and number of elements, so if i have 100000 <ELEMENT_A></ELEMENT_A> (as well as other elements) in file i want to generate 10 new files with 10000 elements each (only the ELEMENT_A elements).
    Wats the easiest and quickest way to do this, code would be welcomed

    The answer depends too much on the situation; for example:
    - are those numbers 100000 and 10000 fixed and known in advance?
    - are all elements first-level children of the document root? Or can they be scattered at various nesting level?
    - do you have enough memory to hold the whole DOM structure for the input document? (1)
    - along hich criteria do you group elements per output file: the first 10000 in input file order, then the next 10000, and so on (2)? Or, you have to sort them along another criteria?
    etc, etc.
    (1) If you have enough memory to hold all such input docs into memory, then the simplest approach would be to load the inut doc as a DOM tree, and iterate over the target elements. This way all subsequent logic (sorting, criteria,...) can be implemented in simple Java methods.
    (2)
    I can program in Java not done much with XML. All i want is solution that works well. ThanksToo bad - for fixed number splitting based on element position in the input doc, XSL would be a better match (using predicates on the elements' position()).
    Doing that in plain java (except if you use Java to run an XSLT over the input XML of course) involves more lines of code, but a better maintenability in the long run if more complex logic has to be taken into account.

  • Insert a xml file without assigning the tablename in the xmldb

    hi guys,
    here comes a interesting question,
    after I registed a xml schema in oracle xml db, oracle create several tables depending on the schema, then I want to insert a xml file that is valided with the register schema and this xml file point to the "schemaurl" .
    If its possible to insert this xml file to oracle xmldb without point out the exact table name in the java program ( in oci driver or thin driver ).
    BTW, I can copy this xml file to oracle xml db repository, oracle insert it to xml table automatically.
    Mark, would you please give me some advice ;-)
    Thanks

    You can call it from JDBC using thin or thick. Thick is preferred...
    package com.oracle.st.xmldb.pm.examples;
    import com.oracle.st.xmldb.pm.common.baseApp.BaseApplication;
    import java.io.ByteArrayInputStream;
    import java.io.InputStream;
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OracleResultSet;
    import oracle.jdbc.OracleTypes;
    import oracle.xdb.XMLType;
    public class CreateResource extends BaseApplication {
        public CreateResource() {
        public void doSomething(String[] Args) throws Exception
          OracleCallableStatement  statement = null;
          String statementText;
          statementText =
          "declare" +
          " res varchar2(5);" +
          "begin " +
          "  if (dbms_xdb.createResource(:1,:2)) then " +
          "    res := 'TRUE';" +
          "  else" +
          "    res := 'FALSE';" +
          "  end if;" +
          "  :3 := res;" +
          "end;";
          XMLType xml;
          // In the real world we would get an InputStream from something more interesting that
          // an in memeory String
          String xmlText = "<Root><Element Attr=\"AttrValue\">A text Node</Element></Root>";
          byte[] byteBuffer = xmlText.getBytes();
          InputStream is = new ByteArrayInputStream(byteBuffer);
          xml = XMLType.createXML(this.getConnection(),is);
          statement = (OracleCallableStatement) getConnection().prepareCall(statementText);
          statement.registerOutParameter(3,OracleTypes.VARCHAR);
          statement.setString(1,"/public/test1.xml");
          statement.setObject(2,xml);
          boolean res = statement.execute();
          String plsqlResult = statement.getString(3);
          System.out.println("The result is " + plsqlResult);
          statement.close();
          getConnection().commit();
          getConnection().close();
        public static void main (String[] args)
         try
           CreateResource example = new CreateResource();
           example.initializeConnection();
           example.doSomething(args);
         catch (Exception e)
           e.printStackTrace();
    }

  • I am in hurry,how to save  the xml file without attributes

    i have the following xml file with attributes,
    <?xml version="1.0"?>
    <Ve2.Configuration>
         <Ve2.Displaymanager>
              <type type="combobox">eVeDisplayStandardType</type>
              <setCounter type="bool">false</setCounter>
              <frames type="textfield">20</frames>
         </Ve2.Displaymanager>
    </Ve2.Configuration>
    but i want to save it without attributes, that means, my saved xml file look like this.:
    <?xml version="1.0"?>
    <Ve2.Configuration>
         <Ve2.Displaymanager>
              <type >eVeDisplayStandardType</type>
              <setCounter >false</setCounter>
              <frames20</frames>
         </Ve2.Displaymanager>
    </Ve2.Configuration>
    how can i do it with java.

    If you know the format of the XML file, then you can write a straight forward XSL file to transform it.
    Paul
    www.codetelligence.com

Maybe you are looking for

  • How to capture the user change in an input field on a selection screen?

    I am coding a selection screen in which there are two input fields. The first field takes a Unix directory from the user input. Based on the input value, the second field will be populated with a the name of a file under the corresponding directory.

  • Mobile PDF signing

    So I have been trying to create a "service report" for our company. I created a form with forms central, and all in all I just love the way it works. I tried doing it via excel and importing into reader to create a form. Maybe I was doing something w

  • PC that ITunes was on died.  Have 2 synced AppleTV's and various backups...

    OK, My dedicated laptop that I used for running Itunes just died and I really don't want to go to the trouble to get it running again. I have two AppleTV's that have my complete music library synced. I have an IPod classic, IPhone, and IPod touch tha

  • New 5c charging dock not working!

    Got a charging dock for my 5c and it does not work.  Called Apple they sent a new one and it does not work either?  I am using the lightning cable provide with phone.  Ear buds do not work either through the dock.  What am i missing?

  • Spry menu problem in IE- showing as white box

    Help please. My spry menus are showing as a white box in Internet Explorer. All other browsers are fine. I am a newbie and don't know how to fix the problem. http://harmonized.harmonized-design.com.