Remove an element from XML present in CLOB column

Hi,
I need to remove element TEST2 and TEST3 from the below XML which is present in the CLOB column of a table. I need to do this using DBMS_XMLDOM package of Oracle as my existing code is using the same -
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>
Hence the final o/p should be like
<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
</LEAF1>
</ROOT>
Please suggest how to achieve this.

Something like this?
Anton
declare
  t_doc dbms_xmldom.DOMDocument;
  t_root dbms_xmldom.DOMNode;
  t_node dbms_xmldom.DOMNode;
  t_buf varchar2(1000);
begin
  t_doc := dbms_xmldom.newDOMDocument( xmltype( '<ROOT>
<LEAF1>
<TEST1>TEXT1</TEST1>
<TEST2>TEXT2</TEST2>
<TEST3>TEXT3</TEST3>
</LEAF1>
</ROOT>' ) );
  t_root := dbms_xmldom.makeNode( t_doc );
  t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST2' ) );
  t_node := dbms_xmldom.removeChild( t_root, dbms_xslprocessor.selectSingleNode( t_root, '/ROOT/LEAF1/TEST3' ) );
  dbms_xmldom.writetoBuffer( t_root, t_buf );
  dbms_output.put_line( t_buf );
end;

Similar Messages

  • How to remove an Element from XML by confirming Attribute of that element

    Hi guys
    I have an XML file where i have all users DB. Now i want to remove a user from that XML file. I want to check an user id attribute which is uniqe with existing users in XML file, if its the same user then delete this user from XML file and save the changes in XML file.
    here is my XML file:
    <?xml version="1.0" encoding="UTF-8"?>
    <users>
    <user id="zahid" password="X8UrUN79avT27LYwUESiliAV328=" name="Zahid Nawaz" phone="9599808" email="[email protected]" role="Tnr+vPuuAAsix8heVWD4mioCgLQ=" />
    <user id="Admin" name="alpha beta" password="fEqNCco3Yq9h5ZUglD3CZJT4lBs=" phone="456782656" email="[email protected]" role="Tnr+vPuuAAsix8heVWD4mioCgLQ=" />
    <user id="Guest" name="beta alpha" password="+ml3yZuAnbaOHFaIjsOL0ARxmzk=" phone="8765432" email="[email protected]" role="+s6D7jAUvcj5ggPMlOLokiJFLpA=" /><user id="Guest1" name="unknown unknown" password="+ml3yZuAnbaOHFaIjsOL0ARxmzk=" phone="123122112" email="[email protected]" role="+s6D7jAUvcj5ggPMlOLokiJFLpA=" />
    </users>for example i want to delete a user which have user id= Guest.
    How can i do it in Java. Any code example please. i am using JDOM document and SAXBuilder for parsing.
    Waiting for your replay.
    Thanks in Advance
    Best regard

    Hi,
    Till now i tried the following code which give null pointer exception at following line
    element.getParentNode().removeChild(element);
         public String removeUserByID(String id) throws Exception{
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                 DocumentBuilder builder = factory.newDocumentBuilder();
                 TransformerFactory tFactory = TransformerFactory.newInstance();
                 Transformer tFormer = tFactory.newTransformer();
                   doc = builder.parse(usersXml);
                 Element element = (Element)doc.getElementsByTagName("user id="+id).item(0);
    //             Remove the node
                 element.getParentNode().removeChild(element);
    //             Normalize the DOM tree to combine all adjacent nodes
                 doc.normalize();
                 FileOutputStream fos = new FileOutputStream(this.usersXml);
                   XMLOutputter out = new XMLOutputter();
                   out.output(((org.jdom.Document)doc), fos);
              /*     Source source = new DOMSource(doc);
                 Result dest = new StreamResult(System.out);
                 tFormer.transform(source, dest);
                 System.out.println();
                 return "true";
              if following line i m trying to use first attribute of my XML file where i am passing a string which is for example like "user id=Guest". id is a string which have user Id "Guest".
    Element element = (Element)doc.getElementsByTagName("user id="+id).item(0);So any suggestion??Whats wrong here?
    Best regards and thanks again 4 ur reply.

  • Remove element from xml using dom.

    i want to remove an element from an xml file using dom.
    i remove the element but the whole content of the file is also deleted.
    how can i rewrite the file.

    vij_ay wrote:
    subject :Remove element from xml,but if empty element in input file then output should be <tag></tag>, not like <tag.xml/>I assume you mean <tag/> but why do you want this? Any application that will not accept this valid XML construct is flawed and a bug report should be raised against it.

  • Kill a thread and remove the element from the vector

    Hi All
    I have attached each Vector element to a thread which I later want to kill and remove that element from the Vector.
    Thread.join(milliseconds) allows this functionality to let the thread die after n milliseconds.
    However, I want to delete this element from the Vector now.
    Can someone please throw some light on this?
    Here the code I have written for this:
    try
         System.out.println(counter);
         int xCoord = generator.irand(25,200);     // X-coord of AP
         int yCoord = generator.irand(25,200);     // Y coord of AP
         listMN.addElement(new MobileNode((int)mnId,new Point2D.Double(xCoord,yCoord)));
         listMNcoords.addElement(new Point2D.Double(xCoord,yCoord));
         for(int i=0;i<vnuBS.returnBSList().size();i++)
              if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=3)&&(vnuBS.returnBSList().get(i).getChannelCounter()>0))
                   double c = exponential() * 10000;
                   long timeToService = (long)c;
                   System.out.println("BS "+vnuBS.returnBSList().get(i).id+" is connected to MN ");
                   vnuBS.returnBSList().get(i).reduceChannelCounter();
                   System.out.println("Channel Counter Value Now: "+vnuBS.returnBSList().get(i).getChannelCounter());
                   mobileNodesThread.addElement(new Thread(listMN.elementAt(mobileNodeCounter)));
                   mobileNodesThread.elementAt(mobileNodeCounter).setName(mobileNodeCounter+"");
                   mobileNodesThread.elementAt(mobileNodeCounter).start();
                   mobileNodesThread.elementAt(mobileNodeCounter).join(100);
    //                              System.out.println("Died");// thread dies after join(t) milliseconds.
                   System.out.println("ListMN getting generated : " + mobileNodesThread.get(mobileNodeCounter));
              else if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=0))
                   listMN.remove(this.listMN.lastElement());                         //dropcall
                   System.out.println("Removed "+mnId);
                   removeCounter++;
                   mnId = mnId--;
                   mobileNodeCounter--;
              mnId = mnId+1;
         Thanks a lot.

    I'm not sure if what you are trying to accomplish is correctly implemented.
    The method join does not kill the thread. It will wait for the specified time for the thread to exit. If you want the thread to run for a specified ammount of time, develop the run method of that thread with that in mind. Do not try to kill it from the outside, but let it terminate itself (gracefull termination).
    Now for your question regarding the vector (you should probably be using ArrayList nowadays): I would implement the observer pattern for this job. Make the threads post an event on the interface when they are done, let the main thread register itself with the threads and synchronize the method that handles the events. In that method you can remove the object from your list.
    I'm not sure if you want to use thread anyhow, could you tell us what it is that you are trying to accomplish?

  • WebDynpro Java: how to remove blank element from Table and Dropdown.

    Hi  Folks
    In a webdynpro application,
    I created a table and witten the below code to populate the table
         IPrivateDummyView.IFirst_TableElement First_Table_Element = null;
         First_Table_Element = wdContext.nodeFirst_Table().createFirst_TableElement();
         First_Table_Element.setF_Value("One");
         wdContext.nodeFirst_Table().addElement(First_Table_Element);
         First_Table_Element = wdContext.nodeFirst_Table().createFirst_TableElement();
         First_Table_Element.setF_Value("2");
         wdContext.nodeFirst_Table().addElement(First_Table_Element);
    As per the code, i got 2 row in the table.
    But , i have one Empty row on top of the table ,  how to get ride of this.
    i find the same problem happening with dropdown too, where i used DDBI, i populated a the content as mention, but i initial 2 row as blank and then i have my own elements ,as per my code.

    >
    > how to remove blank element from Table and Dropdown
    >
    Change selection property of related node to from 0..1 to 1..1 (mandatory)
    Re: DropdownByIndex and empty line (Thread: DropdownByIndex and empty line )
    Re: Can the empty selection be removed from element dropdownbykey(Thread: Can the empty selection be removed from element dropdownbykey )
    Edited by: Anagha Jawalekar on Nov 18, 2008 10:28 PM

  • Delete elements from XML file using DOM and java

    Hi
    I want now is to remove element from my XML file
    for example
    i have following xml
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
              <firstLineText />
              <firstLineText>|line11</firstLineText>
              <firstLineText>|line12</firstLineText>
    </firstLineTexts>
    </printing>how do i remove all elements fireLineText
    my final output should be
    <?xml version="1.0" encoding="UTF-8"?>
    <printing>
    <firstLineTexts>
    </firstLineTexts>
    </printing>How do i do it using DOM,
    I can create instance of DOM and write it using TransformerFactory
    Ashish

    Hi
    I am trying the following code,
    but it is not working
                    NodeList nScene = doc.getElementsByTagName("firstLineTexts");
              NodeList nScene1 = nScene.item(0).getChildNodes();
              for (int i = 0; i < nScene1.getLength(); i++)
                   Node n = nScene1.item(i);
                        nScene.item(0).removeChild(n);
              }

  • How to remove empty tags from XML

    Hello,
    I have a XML file which contains some empty tags and some values with "?". I need to remove all empty tags and tags which have a value "?".
    Sample Data:
    <a>
    <b></b>
    <c> Hello </c>
    <d>world ?</d>
    <e>oracle</e>
    </a>
    Expected result:
    <a>
    <c> Hello </c>
    <e>oracle</e>
    </a>
    Thank you for your time.
    Thanks,
    Edited by: 850749 on Apr 7, 2011 6:25 PM

    Dear Odie,
    May I make your example a bit more complicated by adding an additional complexType, please:
    ---Original ----
    <DEPT>
    <EMPID>1</EMPID>
    <EMPNAME>Martin Chadderton</EMPNAME>
    <SALARY>??</SALARY>
    <SALARYq></SALARYq>
    </DEPT>
    ----- New ----
    <DEPT>
    <EMPID>1</EMPID>
    <EMPNAME>Martin Chadderton</EMPNAME>
    <SALARY>??</SALARY>
    <SALARYq></SALARYq>
    <EMPLMNT_HISTORY>
    <DEVISION>1</DEVISION>
    <FROM_DATE>2011-01-01 </FROM_DATE>
    <TO_DATE></TO_DATE>
    </EMPLMNT_HISTORY>
    </DEPT>
    Your solution works perfectly for <SALARY>, but how would you suggest also to deal with <TO_DATE> ?
    Massive thanks for your help!
    N.B. Just to emphasise, in my case I have 3 levels (complexType > complexType > complexType) and many elements and I would like to know if there is any generic option to say
    to remove all the empty elements from the result, as it causes to the SSJ (Systinet) Webservice to crash.

  • I can't remove Yandex Elements from the Open menu list with right mouse button and Tools menu although I removed Yandex. I think it slows down Firefox.

    I downloaded Freeyoutube downloader from internet and somehow got yandex installed in my computer with toolbars on firefox.Despite I removed Yandex from my computer Yandex elements still stays in open menu when right mouse button clicked and in the Tools menu. I tried to uninstall Firefox, remove yandex registry from windows registry and restart computer, and then reinstall firefox, Yandex elements still hangs there. Firefox is now running very slow compared to the running before Yandex.

    hello, please try all these steps:
    # [[Reset Firefox – easily fix most problems|reset firefox]] (this will keep your bookmarks and passwords)
    # afterwards go to the firefox menu [[Image:New Fx Menu]] > addons > extensions and in case there are still extensions listed there, disable them.
    # finally run a full scan of your system with different security tools like the [http://www.malwarebytes.org/products/malwarebytes_free free version of malwarebytes] and [http://www.bleepingcomputer.com/download/adwcleaner/ adwcleaner] to make sure that adware isn't present in other places of your system as well.
    [[Troubleshoot Firefox issues caused by malware]]

  • Remove Cdata tags from XML body

    Integration Broker message is being publish from the Peoplecode in the savepostchange event of a page......So basically when they click on the save, it is being published.
    ok, I have title field on a page and the user entered special character "&" and there is a HTML definition being used and that definition goes through parsexmlstring function.
    For example In the cust_title field on a page the user entered " A & B"
    I went to the HTML definition and wrapped cust_title field in the CDATA tags like <![CDATA[<Title>%BIND(:8)</Title>]]>
    Now , there is no error, XML is getting published. But in the xml message
    I see Cdata tags and string is appearing exactly as it was entered.....
    But how can I get rid of the Cdata tags from the XML message?

    Dear Odie,
    May I make your example a bit more complicated by adding an additional complexType, please:
    ---Original ----
    <DEPT>
    <EMPID>1</EMPID>
    <EMPNAME>Martin Chadderton</EMPNAME>
    <SALARY>??</SALARY>
    <SALARYq></SALARYq>
    </DEPT>
    ----- New ----
    <DEPT>
    <EMPID>1</EMPID>
    <EMPNAME>Martin Chadderton</EMPNAME>
    <SALARY>??</SALARY>
    <SALARYq></SALARYq>
    <EMPLMNT_HISTORY>
    <DEVISION>1</DEVISION>
    <FROM_DATE>2011-01-01 </FROM_DATE>
    <TO_DATE></TO_DATE>
    </EMPLMNT_HISTORY>
    </DEPT>
    Your solution works perfectly for <SALARY>, but how would you suggest also to deal with <TO_DATE> ?
    Massive thanks for your help!
    N.B. Just to emphasise, in my case I have 3 levels (complexType > complexType > complexType) and many elements and I would like to know if there is any generic option to say
    to remove all the empty elements from the result, as it causes to the SSJ (Systinet) Webservice to crash.

  • How to remove empty lines from xml files after removing nodes from document

    <pre>
    Hi
    <b>i have xml document, which is shown below
    after removing some nodes from the document ,i am getting empty lines in place of removed nodes,how to resolve this and get the proper xml document without any errors</b>
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <!DOCTYPE Message SYSTEM "TRD01.dtd">
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>N</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    <MessageType>T</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>EXM</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>TR</SenderSystemId>
    </Header>
    </Message>
    <ErrorCode>363 </ErrorCode>
    <ErrorEnterPriseId>NIHK</ErrorEnterPriseId>
    <ErrorStatus>1</ErrorStatus>
    <ErrorSystemId>STL</ErrorSystemId>
    <ErrorTimes>31</ErrorTimes>
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    the xml output i am getting is
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <Message>
    <Header>
    <CounterPartyType>CLIENT</CounterPartyType>
    <CreationTime>20134455</CreationTime>
    <MessageType>TRD01</MessageType>
    <RecipientEnterpriseId>N</RecipientEnterpriseId>
    <RecipentSystemId>STL</RecipentSystemId>
    <Remarks>REMARSK</Remarks>
    <SenderEnterpriseId>N</SenderEnterpriseId>
    <SenderSystemId>T</SenderSystemId>
    </Header>
    </Message>
    <b>could you please let me know how to avoid empty lines in the xml doucment output</b>
    this is the method i am using to get the result
    public void ValidateRecord(String xml){
    try{
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = factory.newDocumentBuilder();
    //parse file into DOM
    /*DOMParser parser = new DOMParser();
    parser.setErrorStream(System.err);
    parser.setValidationMode(DTD_validation);
    parser.showWarnings(true);*/
    System.out.println ("HI THIS xml is validation "+xml);
    Resolver res = new Resolver();
    db.setEntityResolver(res);
    Document doc = db.parse(new InputSource(new StringReader(xml)));
    XPathFactory xpf = XPathFactory.newInstance();
    XPath xpath = xpf.newXPath();
    // XPathExpression expression = xpath.compile("//A/B[C/E/text()=13]");
    String xmlpath="/Message/Header/CounterPartyType/text()";
    String xmlpath1="/Message/Header/RecipentSystemId/text()";
    String xmlpath2="/Message/Header/ErrorSystemId/text()";
    XPathExpression expression = xpath.compile(xmlpath);
    XPathExpression expression1 = xpath.compile(xmlpath2);
    Object result = expression.evaluate(doc, XPathConstants.NODE);
    Object result1 = expression1.evaluate(doc, XPathConstants.NODE);
    Node node = (Node) result;
    Node node1 = (Node) result1;
    System.out.println("the values of the string is " +node.getNodeValue());
    System.out.println("the values of the string is " +node1.getNodeValue());
    // for (int i = 0; i < nodes.getLength(); i++) {
    //System.out.println(nodes.item(i).getNodeValue());
    // CAHNGING THE RECEIPENT NODE
    XPathExpression expression2 = xpath.compile(xmlpath1);
    Object result2 = expression2.evaluate(doc, XPathConstants.NODE);
    Node node2 = (Node) result2;
    System.out.println(node2);
    node2.setNodeValue(node1.getNodeValue());
    System.out.println(node2);
    //removing the nodes from document
    String xmlpath3="/Message/Header/ErrorCode";
    String xmlpath4="/Message/Header/ErrorEnterPriseId";
    String xmlpath5="/Message/Header/ErrorStatus";
    String xmlpath6="/Message/Header/ErrorSystemId";
    String xmlpath7="/Message/Header/ErrorTimes";
    XPathExpression expression3 = xpath.compile(xmlpath3);
    Object result3 = expression3.evaluate(doc, XPathConstants.NODE);
    Node node3 = (Node) result3;
    node3.getParentNode().removeChild(node3);
    XPathExpression expression4 = xpath.compile(xmlpath4);
    Object result4 = expression4.evaluate(doc, XPathConstants.NODE);
    Node node4 = (Node) result4;
    System.out.println("node value");
    System.out.println(node4.getParentNode().getNodeName());
    node4.getParentNode().removeChild(node4);
    XPathExpression expression5 = xpath.compile(xmlpath5);
    Object result5 = expression5.evaluate(doc, XPathConstants.NODE);
    Node node5 = (Node) result5;
    node5.getParentNode().removeChild(node5);
    XPathExpression expression6 = xpath.compile(xmlpath6);
    Object result6 = expression6.evaluate(doc, XPathConstants.NODE);
    Node node6=(Node) result6;
    node6.getParentNode().removeChild(node6);
    XPathExpression expression7 = xpath.compile(xmlpath7);
    Object result7 = expression7.evaluate(doc, XPathConstants.NODE);
    Node node7=(Node) result7;
    node7.getParentNode().removeChild(node7);
    // Node b13Node = (Node) expression.evaluate(doc, XPathConstants.NODE);
    //b13Node.getParentNode().removeChild(b13Node);
    doc.normalize();
    doc.normalizeDocument();
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer t = tf.newTransformer();
    t.setOutputProperty(OutputKeys.INDENT, "yes");
    t.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
    t.setOutputProperty(OutputKeys.METHOD,"xml");
    t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
    t.transform(new DOMSource(doc), new StreamResult(System.out));
    catch (Exception e) {
         e.printStackTrace();
    System.out.println(e.getMessage());
    </pre>
    Edited by: user12185243 on Apr 6, 2013 6:38 AM
    Edited by: user12185243 on Apr 6, 2013 6:41 AM
    Edited by: user12185243 on Apr 6, 2013 6:43 AM
    Edited by: user12185243 on Apr 6, 2013 6:45 AM
    Edited by: user12185243 on Apr 6, 2013 9:00 AM

    either this way we can do this
    1)
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    <b> factory.setIgnoringElementContentWhitespace(true); </b>
    DocumentBuilder db = factory.newDocumentBuilder();
    or
    2)
    java.io.StringWriter sw = new java.io.StringWriter();
    StreamResult sr = new StreamResult(sw);
    t.transform(new DOMSource(doc), sr);
    String xml1 = sw.toString().trim();
    <b> xml1=xml1.replaceAll("\\s",""); </b>
    System.out.println(xml1.trim());

  • Set file name with XSLT - receiver channel - elements from XML?

    Dear experts,
    I have an XSLT mapping for a message that is sent via a receiver channel to a customer.
    The customer wants a certain file name which is put toghether by elements from the XML message.
    I have looked at:
    Re: Java Map for writing the file
    The java code and the XSLT work perfectly!
    In the line
    fos = new FileOutputStream(new File("Fixed_" + new Date().getTime() + ".xml"));
    a fixed value, date and time are used for the file name.
    But I need some values from the XML message to create my name. But how do I do that? Can I somehow get values from the XML message through that java function or do I have to adapt the XSLT?
    Can someone please help me!
    Thank you,
    Peter

    Hi Udo, Hello experts,
    Now I do have a problem. I am using this XSL file:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:map="java:java.util.Map"
      xmlns:dyn="java:com.sap.aii.mapping.api.DynamicConfiguration"
      xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">
    <xsl:output indent="no" />
    <xsl:param name="inputparam"/>
    <xsl:template match="/">
        <!-- change dynamic configuration -->
        <xsl:variable name="dynamic-conf" 
            select="map:get($inputparam, 'DynamicConfiguration')" />
        <xsl:variable name="dynamic-key"  
            select="key:create('http://sap.com/xi/XI/System/File', 'FileName')" />
        <xsl:variable name="dummy"
            select="dyn:put($dynamic-conf, $dynamic-key, 'TOOLDATA_.xml')" />
      <xsl:copy-of select="." />
    </xsl:template>
    </xsl:stylesheet>
    But then the output file is only named "TOOLDATA_.xml". So I assume the XSL is working.
    And I am using this Java-file:
    package pi_mappings;
    import com.sap.aii.mapping.api.*;
    import java.io.*;
    import java.util.*;
    public class SetFileName extends AbstractTransformation
         static final int BUFFER = 1024*1000;
        private Map param;
        public SetFileName(){  }
         public void setParameter (Map map)
              param = map;
              if (param == null)
                   param = new HashMap();
         public static void main(String args[])
              try
                   InputStream in = new FileInputStream(args[0]);
                   OutputStream out = new FileOutputStream(args[1]);
                   SetFileName sfn = new SetFileName();
                   //sfn.setParameter(mapOfMap);
                   sfn.execute(in, out);
              catch (Exception e)
                        e.printStackTrace();
        public void execute(InputStream inputstream, OutputStream outputstream)
        throws StreamTransformationException {
              try
                   DynamicConfiguration conf = (DynamicConfiguration) param.get("DynamicConfiguration");
                   DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
                   int len = 0;
                   byte buf[] = new byte[BUFFER];
                   FileOutputStream fos = null;
                   if (conf != null)
                        fos = new FileOutputStream(new File(conf.get(KEY_FILENAME) + new Date().getTime()) ); //sample only
                   else
                        fos = new FileOutputStream(new File("Fixed_" + new Date().getTime() + ".xml"));
                        while ((len = inputstream.read(buf)) > 0)
                             outputstream.write(buf, 0, len);
                             fos.write(buf, 0, len);
                        fos.close();          
              catch(Exception e){ e.printStackTrace();}
         public void transform(TransformationInput arg0, TransformationOutput arg1)
         throws StreamTransformationException {
              getTrace().addInfo("JAVA Mapping Called");
         this.execute(arg0.getInputPayload().getInputStream(), arg1
              .getOutputPayload().getOutputStream());
    Could you please help me find the mistake. I tried to test it locally by changing the main-method but I could not get it to work.
    Thank you very much for any ideas!
    Best regards,
    Peter

  • Why can't got element from XML

    I try to load an XML element from an XML file using
    HTTPService Object . But The loaded object always null .
    Here is my XML Content
    <?xml version="1.0" standalone="no"?>
    <manifest identifier="imsmanifest.xml" version="1.3"
    xmlns="
    http://www.imsglobal.org/xsd/imscp_v1p1"
    xmlns:adlcp="
    http://www.adlnet.org/xsd/adlcp_v1p3"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_v1p3"
    xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.imsglobal.org/xsd/imscp_v1p1
    imscp_v1p1.xsd
    http://www.adlnet.org/xsd/adlcp_v1p3
    adlcp_v1p3.xsd
    http://www.adlnet.org/xsd/adlseq_v1p3
    adlseq_v1p3.xsd
    http://www.imsglobal.org/xsd/imsss
    imsss_v1p0.xsd">
    <metadata>
    <schema>ADL SCORM</schema>
    <schemaversion>CAM 1.3</schemaversion>
    </metadata>
    <organizations default="default_org">
    <organization identifier="default_org">
    <title>example_1</title>
    <item identifier="lesson1"
    identifierref="lesson1_ref">
    <title>Lesson_1_Interface</title>
    <imsss:sequencing xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_vlp3">
    <imsss:controlMode choiceExit="true" />
    </imsss:sequencing>
    </item>
    <item identifier="lesson2"
    identifierref="lesson2_ref">
    <title>Lesson_2_Toolbox</title>
    <imsss:sequencing xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_vlp3">
    <imsss:controlMode choiceExit="false" />
    </imsss:sequencing>
    </item>
    <item identifier="lesson3"
    identifierref="lesson3_ref">
    <title>Lesson_3_Palettes</title>
    <imsss:sequencing xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_vlp3">
    <imsss:controlMode choiceExit="true" />
    </imsss:sequencing>
    </item>
    <item identifier="lesson4"
    identifierref="lesson4_ref">
    <title>Lesson_4_Layers</title>
    <imsss:sequencing xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_vlp3">
    <imsss:controlMode choiceExit="true" />
    </imsss:sequencing>
    </item>
    <imsss:sequencing xmlns:imsss="
    http://www.imsglobal.org/xsd/imsss"
    xmlns:adlseq="
    http://www.adlnet.org/xsd/adlseq_vlp3">
    <imsss:controlMode flow="false" forwardOnly="true"
    choice="true" />
    </imsss:sequencing>
    </organization>
    </organizations>
    <resources>
    <resource identifier="lesson1_ref"
    adlcp:scormType="asset" type="webcontent" href="no title/Lesson 1
    -- Interface/Lesson1.htm">
    <file href="no title/Lesson 1 -- Interface/Lesson1.htm"
    />
    <file href="no title/Lesson 1 --
    Interface/images/headertop.gif" />
    <file href="no title/Lesson 1 --
    Interface/images/headerside.gif" />
    <file href="no title/Lesson 1 --
    Interface/images/pssidebar.gif" />
    <file href="no title/Lesson 1 --
    Interface/images/LessonTitle1.gif" />
    <file href="no title/Lesson 1 --
    Interface/images/interfacesmall.jpg" />
    <file href="no title/Lesson 1 --
    Interface/images/EndOfLesson.gif" />
    </resource>
    <resource identifier="lesson2_ref"
    adlcp:scormType="asset" type="webcontent" href="no title/Lesson 2
    -- Toolbox/Lesson2.htm">
    <file href="no title/Lesson 2 -- Toolbox/Lesson2.htm"
    />
    <file href="no title/Lesson 2 --
    Toolbox/images/headertop.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/headerside.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/pssidebar.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/LessonTitle2.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/toolbox.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/selectiontools.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/enhancementtools.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/navagationtools.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/ZoomToolIcon.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/HandTool.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/colorselect.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/eyedroppertool.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/eyedroppertool.gif" />
    <file href="no title/Lesson 2 --
    Toolbox/images/EndOfLesson.gif" />
    </resource>
    <resource identifier="lesson3_ref"
    adlcp:scormType="asset" type="webcontent" href="no title/Lesson 3
    -- Palettes/Lesson3.htm">
    <file href="no title/Lesson 3 -- Palettes/Lesson3.htm"
    />
    <file href="no title/Lesson 3 --
    Palettes/images/headertop.gif" />
    <file href="no title/Lesson 3 --
    Palettes/images/headerside.gif" />
    <file href="no title/Lesson 3 --
    Palettes/images/pssidebar.gif" />
    <file href="no title/Lesson 3 --
    Palettes/images/LessonTitle3.gif" />
    <file href="no title/Lesson 3 --
    Palettes/images/defaultpalettes.gif" />
    <file href="no title/Lesson 3 --
    Palettes/images/EndOfLesson.gif" />
    </resource>
    <resource identifier="lesson4_ref"
    adlcp:scormType="asset" type="webcontent" href="no title/Lesson 4
    -- Layers/Lesson4.htm">
    <file href="no title/Lesson 4 -- Layers/Lesson4.htm"
    />
    <file href="no title/Lesson 4 --
    Layers/images/headertop.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/headerside.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/pssidebar.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/LessonTitle4.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/flatlayers.gif" />
    <file href="no title/Lesson 4 -- Layers/images/37.gif"
    />
    <file href="no title/Lesson 4 --
    Layers/images/layers.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/layerarrows.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/eyeicon.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/paintbrush.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/linkicon.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/newlayericon.gif" />
    <file href="no title/Lesson 4 --
    Layers/images/EndOfLesson.gif" />
    </resource>
    </resources>
    </manifest>
    quote:
    Text
    For example , i want to get metadata element .
    var nodes:XML = XML(myManifestSrv.lastResult.metadata);
    trace(nodes)
    quote:
    Text

    Follow your suggestion , i use AS style to load the XML.
    below is my full code , it's an AIR application .
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute" initialize="init()">
    <mx:Script>
    <![CDATA[
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;
    public var myManifestSrv:HTTPService;
    private function init():void{
    myManifestSrv = new HTTPService();
    myManifestSrv.url = "datas/example1/imsmanifest.xml";
    myManifestSrv.resultFormat = "e4x";
    myManifestSrv.addEventListener(ResultEvent.RESULT ,
    manifestLoaded);
    myManifestSrv.send();
    private function manifestLoaded(event:Event):void{
    var nodes:XML = XML(myManifestSrv.lastResult.metadata);
    trace(nodes);
    ]]>
    </mx:Script>
    </mx:WindowedApplication>
    you can try my code ,
    trace(myManifestSrv.lastResult.metadata) is still null.
    I am not quite sure whether the resaon of fault is from XML
    problem .When i use a simple XML , such as :
    <?xml version="1.0" encoding="UTF-8"?>
    <galleries>
    <gallery id="flextravel">
    <description>Trip photos from various Flex team
    members</description>
    <photo>
    <name>Acropolis: Matt Chotin</name>
    <description>Acropolis on Calton Hill in
    Edinburgh</description>
    <source>flextravel/Acropolis on Calton
    Hill.jpg</source>
    </photo>
    <photo>
    <name>Edinburgh Castle: Matt Chotin</name>
    <description>The Edinburgh Castle as seen from
    fountain in the Princess Gardens</description>
    <source>flextravel/Fountain and Edinburgh
    Castle.jpg</source>
    </photo>
    </gallery>
    </galleries>
    It is OK.

  • Removing specific element from a list

    Hello, I'm very new to java, and to programming in general.
    I'm trying to write a secret santa app for my family for christmas. Essentially the idea is that 7 names are put into a list, and each time a name is "pulled" (i.e. randomly assigned to a name /= itself) it will be removed from the list of available names to assign.
    String[] nList = { name2, name3, name4, name5, name6, name7 }; // store names for random use
    Random r = new Random();
    name1assign = nList[r.nextInt(nList.length)];
    String[] nList2 = { name1, name3, name4, name5, name6, name7 };
    name2assign = nList2[r.nextInt(nList2.length)];
    My goal for this is to take the string that is equal to name1assign, and remove an element with that string from nList2.
    Can anyone give me some advice in this matter?
    Thanks.

    Sometimes a null value is used to indicate an 'empty' array element, but it would be better to try collections instead.
    You could use an ArrayList instead of an array. This has methods to remove items by index or value.
    An ArrayList also works with Collections.shuffle, which allows you to simply iterate over the list and not deal with random or removing elements at all.

  • Removing Incorrect data from .xml files

    How do I remove info in the .xml files.
    When I 1st got my kit it read my fastest km as 4.55mins/km
    This is way too fast as my average is 6.00mins/km.
    Because the info is incorrect I am not getting congratulated by Paula or being able to improve slowly as I will never get to 4.55.
    HELP

    Haplogroup k,
    I think you have understood me. The file was created
    when the unit wasn't callibrated and recorded a false
    reading which was way too fast for me and a lot of
    runners also.
    I want to post best results now that the machine
    works right.
    Most people have said that they were amazed by how accurate the Nike+ was right from the box without calibration. But I'll take your word for it.
    I can get to the .xml files but it won't delete
    records, that's all I want to do.
    I don't know what you mean by "it won't delete records." Are you talking about your Personal Bests? No you cannot edit that fle. But you can delete a run from your Nano.
    However, you can save all your run data to your computer hard-drive, then RESTORE your Nano. But that will also wipe your calibration data and everything else (personal bests). I guess you could then recalibrate before doing any runs. Then put your old run data (your old xml files) back in your "latest" folder.

  • Removing Default Namespaces from XML

    Hi All,
    I am having a situation where I can't remove the default
    namespace from XML mainly
    because there is no namespace prefix.
    I hope this code snipped makes better sense.
    function test():void
    document:XML =
    <test xmlns:soap="
    http://example.com" xmlns="
    http://swanmokshi.com">
    <item>peter</item>
    <item>jenny</item>
    <item>JK Angel</item>
    <test>
    // I can remove the soap namespace by doing the following
    soap:Namespace = document.namespace("soap");
    document.removeNamespace(soap).
    Alert.show(document.toXMLString()); // should now display
    the xml document without the soap namespace
    Note that removing the soap namespace is easy because of the
    first namespace is named "soap". How do
    I removed the unnamed namespace, xmlns="
    http://swanmokshi.com" ?
    regards,
    Arun

    Same problem for me.
    XPath expression failed to execute. Error while processing xpath expression, the expression is "ora:processXSLT("Transformation_2.xsl", bpws:getVariableData("PartyID", "Header"))", the reason is Character reference "&#24" is an invalid XML character.. Please verify the xpath query.
    I am getting the date from Oracle Advanced Queue

Maybe you are looking for

  • My iPod touch keeps crashing while playing a game

    I downloaded recently Dinner Dash Rush and in the beginning it was fine, playing the time I wanted but in these last few days I start playing the game and suddenly it crashes. I have tried turning the ipod off and on but after like the second time pl

  • AS 2.0 Class runtime loading problem

    Hi all i work in a company who is developing an impressive sized flash web application. flash application development, involving many swf files that share the same classes, creates a potential problem which is very difficult for us to avoid: say you

  • Adobe form: all employees  list in a single pdf----URGENT

    Hi experts, I have one adobe form, which is giving output correctly. input : 10 employees. output in pdf : pdf is coming in output.if i want to save the file, each employee data is storing in a separate file. my requirement : i need to save all the e

  • ThinkPad t420 cant power on after some water...

    An accident happened today morning. I was drinking above my laptop and accidently some juice is spilled into the keyboard of my T420. After that I plugged out the AC and removed the battery immadiately. It dried out and I tried to power it on. The wi

  • Error message when opening a pdf

    he application wants to display a pdf on your device.there is a known bug in the pdf loading  code that makes the running of arbitrary code possible,which could compromise your sistem.are  you sure you sure you want to continue iPad 2