Strip off markups of generic XML data with E4X

I have a generic XML file:
<nodes>
<node1 att1='abc' att2='xyz'>
<ele1> Hello </ele1>
<ele2> Hi </ele2>
</node1>
</nodes>
The tag and attribute names above can be anything. I need a
generic method to strip off the XML markups and display the
contents as:
node1@att1: abc
node1@att2: xyz
node1.ele1: Hello
node1.ele2: Hi
How can E4X do this?

e4x is for manipulating/navigating your xml. But you can use
it inside a for/each loop to look at your xml nodes and extract the
strings without the xml tags using toString().
Search the help docs for "XML type conversion" and see the
toString() method in action.

Similar Messages

  • Store xml data with difference dtd in the same xmltype column?

    Hi, all!
    I want to know, whether i can store the xml data with difference DTD in the same xmltype column.
    thank you for your help
    rabbit

    As long as the column is not based on an XML Schema

  • Problem when decrypting an encrypted xml data with arabic data

    Hi all
    I have problem in decryption an encrypted Xml file. because my Xml file contains utf-8 characters, this problem occurs. after many proccess on Xml data the following code throws an Exception:
    try {
    // Works if the content is a single child element.
    byte [] a = decbit.getBytes("UTF-8");
    ByteArrayInputStream bais2 = new ByteArrayInputStream(a);
    Document decdoc = docBuilder.parse(bais2);
    Node decNode =
    encDoc.importNode(decdoc.getFirstChild(), true);
    edata.getParentNode().replaceChild(decNode,edata);
    }catch(org.xml.sax.SAXParseException spe) {
    //In case the content is plain text
    //or a group of child elements
    Text decText = encDoc.createTextNode(decbit);
    edata.getParentNode().replaceChild(decText,edata);
    decString = (getString((XmlDocument)encDoc));
    at the line with code "Document decdoc = docBuilder.parse(bais2); " an Exception occurs with message :
    org.xml.sax.SAXParseException: Illegal character at end of document, &#x3c;.
    whereas when I debug the project the filed "decbit", contains correct data. any way, in order to the exception, the control move to "catch" block and create a Text Node but the problem is the replaced data is like this:
    <id root="588588588" extension="" displayable="false" /><beneficiaryOf typeCode="BEN">
    <policyOrAccount classCode="COV" moodCode="EVN">
    <id xsi:type="II" root="855855855" extension="" displayable="false" />
    <author typeCode="AUT">
    <carrierRole classCode="UNDWRT">
    <id root="6548888888" extension="" displayable="false" />
    </carrierRole>
    </author>
    </policyOrAccount>
    </beneficiaryOf>
    as you can see, tha "<" characters are < and the ">" characters are >
    this really exhausted me, please help me out.
    thank you, any help will be appreciated
    regards
    Mohammad

    Hi Naveen,
    In sxmb_moni the content transmitted to the adapter(RFC)is as follows
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    - <RECORDS>
    - <item>
      <FLOC>f1-01-01</FLOC>
      <RFID_NO>I006</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-02</FLOC>
      <RFID_NO>I002</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-03</FLOC>
      <RFID_NO>I003</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-04</FLOC>
      <RFID_NO>I004</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-05</FLOC>
      <RFID_NO>I005</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-06</FLOC>
      <RFID_NO>I001</RFID_NO>
      </item>
      </RECORDS>
      </ns:ZRFID_EQUIP>
    At r/3 side the field floc and rfid_no gets mapped to floc which is of char30
    eg floc=f1-01-01I006
       rfid_no=

  • Problem inserting and querying XML data with a recursive XML schema

    Hello,
    I'm facing a problem with querying XML data that is valid against a recursive XML Schema. I have got a table category that stores data as binary XML using Oracle 11g Rel 2 on Windows XP. The XML Schema is the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>I registered this schema and created the category table. Then I inserted a new row using the code below:
    insert into category_a values
    (XMlElement("category",
          xmlattributes('categoryAAA' as "id"),
          xmlforest ('ma categ' as "name"),
          (xmlelement("description", (xmlelement("text", 'find doors blest now whiles favours carriage tailor spacious senses defect threat ope willow please exeunt truest assembly <keyword> staring travels <bold> balthasar parts attach </bold> enshelter two <emph> inconsiderate ways preventions </emph> preventions clasps better affections comes perish </keyword> lucretia permit street full meddle yond general nature whipp <emph> lowness </emph> grievous pedro')))    
    The row is successfully inserted as witnessed by the results of row counting. However, I cannot extract data from the table. First, I tried using SqlPlus* which hangs up and quits after a while. I then tried to use SQL Developer, but haven't got any result. Here follow some examples of queries and their results in SQL Developer:
    Query 1
    select * from category
    Result : the whole row is returned
    Query 2
    select xmlquery('$p/category/description' passing object_value as "p" returning content) from category
    Result: "SYS.XMLTYPE"
    now I tried to fully respect the nested structure of description element in order to extract the text portion of <bold> using this query
    Query 3
    select  xmlquery('$p/category/description/text/keyword/bold/text()' passing object_value as "p" returning content) from  category_a
    Result: null
    and also tried to extract the text portion of element <text> using this query
    Query 4
    select  xmlquery('$p/category/description/text/text()' passing object_value as "p" returning content) from  category_a
    Result: "SYS.XMLTYPE".
    On the other hand, I noticed, from the result of query 1, that the opening tags of elements keyword and bold are encoded as the less than operator "&lt;". This explains why query 3 returns NULL. However, query 4 should display the text content of <text>, which is not the case.
    My questions are about
    1. How to properly insert the XML data while preserving the tags (especially the opening tag).
    2. How to display the data (the text portion of the main Element or of the nested elements).
    The problem about question 1 is that it is quite unfeasible to write a unique insert statement because the structure of <description> is recursive. In other words, if the structure of <description> was not recursive, it would be possible to embed the elements using the xmlelement function during the insertion.
    In fact, I need to insert the content of <description> from a source table (called category_a) into a target table (+category_b+) automatically .
    I filled category_a using the Saxloader utility from an flat XML file that I have generated from a benchmark. The content of <description> is different from one row to another but it is always valid with regards to the XML Schema. The data is properly inserted as witnessed by the "select * from category_a" instruction (500 row inserted). Besides, the opening tags of the nested elements under <description> are preserved (no "&lt;"). Then I wrote a PL/SQL procedure in which a cursor extracts the category id and category name into varchar2 variables and description into an XMLtype variable from category_a. When I try to insert the values into a category_b, I get the follwing error:
    LSX-00213: only 0 occurrences of particle "text", minimum is 1which tells that the <text> element is absent (actually it is present in the source table).
    So, my third question is why are not the tags recognized during the insertion?
    Can anyone help please?

    Hello,
    indded, I was using an old version of Sqlplus* (8.0.60.0.0) because I had a previous installation (oracle 10g XE). Instead, I used the Sqlplus* shipped with the 11g2database (version 11.2.0.1.0). All the queries that I wrote work fine and display the data correctly.
    I also used the XMLSERIALIZE function and can now display the description content in SQL Developer.
    Thank you very much.
    To answer your question Marco, I registered the XML Schema using the following code
    declare
      doc varchar2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>';
    begin
      dbms_xmlschema.registerSchema('/xmldb/category_auction.xsd', doc,     LOCAL      => FALSE, 
            GENTYPES   => FALSE,  GENBEAN    => FALSE,   GENTABLES  => FALSE,
             FORCE      => FALSE,
             OPTIONS    => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
             OWNER      => USER);
    end;then, I created the Category table as follows:
    CREATE TABLE category_a of XMLType XMLTYPE store AS BINARY XML
        XMLSCHEMA "xmldb/category_auction.xsd" ELEMENT "category";Now, there still remains a problem of how to insert the "description" content which I serialized as a CLOB data into another table as XML. To this purpose, I wrote a view over the Category_a table as follows:
    CREATE OR REPLACE FORCE VIEW "AUCTION_XWH"."CATEGORY_V" ("CATEGORY_ID", "CNAME", "DESCRIPTION") AS
      select category_v."CATEGORY_ID",category_v."CNAME",
      XMLSerialize(content ( xmlquery('$p/category/description/*' passing object_value as "p" returning content)) as clob) as "DESCRIPTION"
      from  auction.category_a p, 
    xmltable ('$a/category' passing p.Object_Value as "a"
    columns  category_id varchar2(15) path '@id',
              cname varchar2(20) path 'name') category_v;Then, I wrote a procedure to insert data into the Category_xwh table (the source and target tables are slightly different: the common elements are just copied wereas new elements are created in the target table). The code of the procedure is the following:
    create or replace PROCEDURE I_CATEGORY AS
    v_cname VARCHAR2(30);
    v_description clob ;
    v_category_id VARCHAR2(15);
    cursor mycursor is select category_id, cname, description from category_v;
    BEGIN
    open mycursor;
      loop
      /*retrieving the columns*/
      fetch mycursor into v_category_id, v_cname, v_description ;
      exit when mycursor%notfound;
      insert into category_xwh values
      (XMlElement("category",
          xmlattributes(v_category_id as "category_id"),
          xmlelement("Hierarchies", xmlelement("ObjHierarchy", xmlelement ("H_Cat"),
                                                               xmlelement ("Rollsup",
                                                                                  (xmlelement("all_categories",
                                                                                   xmlattributes('allcategories' as "all_category_id")))
        xmlforest (
                  v_cname as "cat_name",
                  v_description as "description")    
    end loop;
      commit;
      close mycursor;
    END I_CATEGORY;When I execute the procedure, I get the following error:
    LSX-00201: contents of "description" should be elements onlyso, I just wonder if this is because v_description is considered as plain text and not as XML text, even if its content is XML. Do I need to use a special function to cast the CLOB as XML?
    Thanks for your help.
    Doulkifli

  • XML data with nested repeating nodes

    First let me prelude with my skill set; "I am an XML,
    JavaScript and Spry newbie". My xml data looks like this:
    <report>
    <header>
    <column type="[string|real|int]>some
    value</column>
    <column type="[string|real|int]>some
    value</column>
    </header>
    <details>
    <row>
    <cell type="[string|real|int]">some value</cell>
    <cell type="[string|real|int]">some value</cell>
    </row>
    <row>
    <cell type="[string|real|int]">some value</cell>
    <cell type="[string|real|int]">some value</cell>
    </row>
    </details>
    </report>
    - report/header/column is completely dynamic and not known in
    advance
    - each report/header/column is the table column name value
    - each report/details/row/cell is the table cell value
    - type="[string|real|int]" is data type of the cell value
    Using Spry 1.5 I have been able to successfully populate the
    table column header row dynamically and repeat the appropriate
    number of rows.
    Spry is Cool!
    I have not been able to figure out how to repeat
    report/details/row/cell for each repeating row node. If I nest
    spry:repeat it appears to go into an endless loop.
    I will also need to equate data type to a Spry data type so
    that I may sort the columns appropriately for their respective data
    type.
    Here is the code I have so far:
    <script language="JavaScript" type="text/javascript"
    src="includes/xpath.js"></script>
    <script language="JavaScript" type="text/javascript"
    src="includes/SpryData.js"></script>
    <script language="JavaScript" type="text/javascript"
    src="includes/SpryNestedXMLDataSet.js"></script>
    <script type="text/javascript">
    var dsReport = new
    Spry.Data.XMLDataSet("data/cmbcov_raw.xml", "/iqreport");
    var dsHeaders = new Spry.Data.NestedXMLDataSet(dsReport,
    "header/column");
    var dsRows = new Spry.Data.NestedXMLDataSet(dsReport,
    "details/row");
    var dsCells = new Spry.Data.NestedXMLDataSet(dsReport,
    "details/row/cell");
    Spry.Data.Region.debug = true;
    </script>
    <link href="/report/css/samples.css" rel="stylesheet"
    type="text/css" media="all" />
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Reports</title>
    </head>
    <body>
    <h3
    spry:region="dsReport">{dsReport::@title}</h3>
    <div class="liveSample" spry:region="dsReport dsHeaders
    dsRows dsCells">
    <table class="dataTable">
    <tr>
    <th
    spry:repeat="dsHeaders">{dsHeaders::column}</th>
    </tr>
    <tbody>
    <tr spry:repeat="dsRows">
    <td>{dsCells::cell}</td> <!--if I use
    spry:repeat here browser hangs - endless loop?-->
    </tr>
    </tbody>
    </table>
    </div>
    </body>
    </html>
    Your assistance will be greatly appreciated!
    Thank you in advance,
    nomadcanuck

    Don,
    Thanks for forcing me to read the nested data set sample
    again, three times the charm as they say :). I made the following
    addition to get it to work.
    var dsDetails = new Spry.Data.NestedXMLDataSet(dsReport,
    "details");
    var dsRows = new Spry.Data.NestedXMLDataSet(dsDetails,
    "row");
    var dsCells = new Spry.Data.NestedXMLDataSet(dsRows, "cell");
    <tbody spry:repeat="dsDetails">
    <tr spry:repeat="dsRows">
    <td spry:repeat="dsCells">{dsCells::cell}</td>
    </tr>
    </tbody>
    I am still stumped with respect to sorting the dynamic
    header/column. Any chance of being pointed in the right direction,
    either document or hint is appreciated.
    Thanks again,
    nomadcanuck

  • How to get & use xml data with jstl libraries? (URGENT PLZ)

    I am using jstl to get and use xml data
    I needs to perform operations on the parsed xml document with other libraries of jstl. How can i do that.
    I used Dom variable to parse my document as:
    <x:parse varDom="test"> <c:import url="project.xml"/> </x:parse>
    where my project.xml is:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <project>      <projectName>myProject</projectName> </project>
    I can dislay this value in html by
    <x:out select="$test/project/projectName"/>
    But I need a string value sotred in variable such as <c:set var="pname" value="???">
    HOW CAN I SET THIS VALUE IN CORE VARIABLE THAT IS, USING <c:set...> SO THAT IT CAN BE USED ANYWHERE IN JSP PAGE TO CONCATE RETURNED STRING IN OTHER STRING VARIABLES DEFINED BY CORE LIB?
    Jessy
    Message was edited by:
    jessy
    Message was edited by:
    jessy

    I believe that <c:set> should do that but i am facing problem in it. Look into this jsp scriptlet:
    1-<x:parse varDom="test"> <c:import url="project.xml"/> </x:parse>
    2-<x:set var="ds" select="$test/project/projectName"/>
    3-<x:out select="$ds"/> <br>
    4-<c:set var="tt" value="${ds}" />
    5-<c:out value="${tt}" />
    In line 3 variable ds returns: myProject
    In line 5 variable tt returns: [[projectName: null]]
    perhaps on line 4 ds is storing some array to tt and i am not calling correct array element. I tried many options but still could not find solution. Plz Plz do something urgent for me. Thanks
    Jessy
    Message was edited by:
    jessy

  • C# load xml data with attributes to datagridview; update data and save back to the xml

    Hi guys,
    i currently have this XML as data
    <DEALS>
    <DEAL ID="22" ISBN="0-7888-1623-3" Screenplay="Mary Kaplan" Title ="Mr Gentleman" Director = "Jonathan Jones">
    <ALLOCATION DEMANDE="5000" CODE="72" PRICE="25.00">2500</ALLOCATION>
    <ALLOCATION DEMANDE="7000" CODE="75" PRICE="35.00">4000</ALLOCATION>
    </DEAL>
    <DEAL ID="23" ISBN="1-7988-1623-3" Screenplay="Joe Doe" Title ="Nothing Much" Director = "Listentome">
    <ALLOCATION DEMANDE="3300" CODE="72" PRICE="15.00">2500</ALLOCATION>
    </DEAL>
    </DEALS>
    I load the data with the code below:
    i use xDocument to load the DealData.xml and then put it in ToString.
    //outside of the form
    public static class XElementExtensions
    public static DataTable ToDataTable(this XElement element)
    DataSet ds = new DataSet();
    string rawXml = element.ToString();
    ds.ReadXml(new StringReader(rawXml));
    return ds.Tables[0];
    public static DataTable ToDataTable(this IEnumerable<XElement> elements)
    return ToDataTable(new XElement("Root", elements));
    //in the form
    private void button2_Click(object sender, EventArgs e)
    var xDocument = XDocument.Load("DealData.xml");
    string txtxml = xDocument.ToString();
    StringReader reader = new StringReader(txtxml);
    XDocument doc1 = XDocument.Load(reader);
    var res = doc1.Descendants("DEAL").ToList().Where(x => x.Attribute("ID").Value == "22").Descendants("ALLOCATION");
    dataGridView1.DataSource = res.ToDataTable();
    Now my question is:
    I would like to update the data from the DataGridview with the Attribute("ID").Value == "22" and save the data back to the XML.
    For example, after I load my data on the datagridview, we only pickup anything that is in the node
    <DEAL ID="22" ISBN="0-7888-1623-3" Screenplay="Mary Kaplan" Title ="Mr Gentleman" Director = "Jonathan Jones">
    <ALLOCATION DEMANDE="5000" CODE="72" PRICE="25.00">2500</ALLOCATION>
    <ALLOCATION DEMANDE="7000" CODE="75" PRICE="35.00">4000</ALLOCATION>
    </DEAL>
    I updated the datagridview below with DEMANDE = 9000 CODE = 66 PRICE = 24.77 AND ALLOCATION = 1200
    I want be able to extract the data back in the xml as a child of the DEAL ID = "22"
    So that the XML file looks like this 
    <DEALS>
    <DEAL ID="22" ISBN="0-7888-1623-3" Screenplay="Mary Kaplan" Title ="Mr Gentleman" Director = "Jonathan Jones">
    <ALLOCATION DEMANDE="5000" CODE="72" PRICE="25.00">2500</ALLOCATION>
    <ALLOCATION DEMANDE="7000" CODE="75" PRICE="35.00">4000</ALLOCATION>
    <ALLOCATION DEMANDE="9000" CODE="66" PRICE="24.77">1200</ALLOCATION> <-! this is the new line !->
    </DEAL>
    <DEAL ID="23" ISBN="1-7988-1623-3" Screenplay="Joe Doe" Title ="Nothing Much" Director = "Listentome">
    <ALLOCATION DEMANDE="3300" CODE="72" PRICE="15.00">2500</ALLOCATION>
    </DEAL>
    </DEALS>
    Is there a way to achieve that?
    I have been searching and reading in the books but i cannot find a solution for this.
    Thank you
    Please do not forget to click “Vote as Helpful” if the reply helps/directs you toward your solution and or "Mark as Answer" if it solves your question. This will help to contribute to the forum.

    I would think of something like the below, the id is passed as static you need to change this
    protected virtual void button1_Click(object sender, EventArgs e)
    //Get DataTable from DGV datasource
    DataTable dt = new DataTable();
    dt = (DataTable)dataGridView1.DataSource;
    string file1 = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><DEALS><DEAL ID=\"22\" ISBN=\"0-7888-1623-3\" Screenplay=\"Mary Kaplan\" Title =\"Mr Gentleman\" Director = \"Jonathan Jones\"><ALLOCATION DEMANDE=\"5000\" CODE=\"72\" PRICE=\"25.00\">2500</ALLOCATION><ALLOCATION DEMANDE=\"7000\" CODE=\"75\" PRICE=\"35.00\">4000</ALLOCATION></DEAL><DEAL ID=\"23\" ISBN=\"1-7988-1623-3\" Screenplay=\"Joe Doe\" Title =\"Nothing Much\" Director = \"Listentome\"><ALLOCATION DEMANDE=\"3300\" CODE=\"72\" PRICE=\"15.00\">2500</ALLOCATION></DEAL></DEALS>";
    StringReader reader = new StringReader(file1);
    XDocument doc1 = XDocument.Load(reader);
    //Remove all elements related to the id being populated into the Grid
    doc1.Descendants("DEAL").ToList().Where(x => x.Attribute("ID").Value == "22").Descendants("ALLOCATION").Remove();
    //loop through datatable and create new xelement to be added to the xdocument
    foreach (DataRow dr in dt.Rows)
    XElement xe = new XElement("ALLOCATION",
    new XAttribute("DEMANDE", dr[0].ToString()),
    new XAttribute("CODE", dr[1].ToString()),
    new XAttribute("PRICE", dr[2].ToString()));
    xe.Value = dr[3].ToString();
    doc1.Descendants("DEAL").ToList().Where(x => x.Attribute("ID").Value == "22").FirstOrDefault().Add(xe);
    Fouad Roumieh

  • Transforming XML Data with XSLT in a servlet

    Trying to transform XML data using XSLT. The following code works fine outside of a servlet. But in a servlet it gives the following error :
    * Transformer Factory error
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
    javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: org.xml.sax.SAXException: Namespace not supported by SAXParser
         at org.apache.xml.utils.DefaultErrorHandler.fatalError(DefaultErrorHandler.java:257)
         at org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:813)
         at TransformationApp.XSLTTransformServlet.MyTransform(XSLTTransformServlet.java:79)
         at TransformationApp.XSLTTransformServlet.doGet(XSLTTransformServlet.java:39)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
         at org.apache.tomcat.core.Handler.service(Handler.java:287)
         at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
         at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
         at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
         at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
         at java.lang.Thread.run(Thread.java:484)
    Several articles hinted at setting the factory namespace attribute to TRUE. I have tried that but same results. Here is the code :
    static Document document;
    DocumentBuilderFactory factory =
    DocumentBuilderFactory.newInstance();
    //factory.setNamespaceAware(true);
    //factory.setValidating(true);
    try {
    File stylesheet = new File(argv[0]);
    File datafile = new File(argv[1]);
    DocumentBuilder builder = factory.newDocumentBuilder();
    document = builder.parse(datafile);
    // Use a Transformer for output
    TransformerFactory tFactory =
    TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource(stylesheet);
    Transformer transformer = tFactory.newTransformer(stylesource);
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(System.out);
    transformer.transform(source, result);
    } catch (TransformerConfigurationException tce) {
    // Error generated by the parser
    System.out.println ("\n** Transformer Factory error");
    System.out.println(" " + tce.getMessage() );
    // Use the contained exception, if any
    Throwable x = tce;
    if (tce.getException() != null)
    x = tce.getException();
    x.printStackTrace();
    } catch (TransformerException te) {
    // Error generated by the parser
    System.out.println ("\n** Transformation error");
    System.out.println(" " + te.getMessage() );
    // Use the contained exception, if any
    Throwable x = te;
    if (te.getException() != null)
    x = te.getException();
    x.printStackTrace();
    } catch (SAXException sxe) {
    // Error generated by this application
    // (or a parser-initialization error)
    Exception x = sxe;
    if (sxe.getException() != null)
    x = sxe.getException();
    x.printStackTrace();
    } catch (ParserConfigurationException pce) {
    // Parser with specified options can't be built
    pce.printStackTrace();
    } catch (IOException ioe) {
    // I/O error
    ioe.printStackTrace();
    Any help would be greatly appreciated.

    I don't know that this is true, but i think the problem is the classpath.
    The runtime has his own parser. This parser is befor your xalan.lib in the classpath and the
    parser from the runntime don't support namespace.
    Try Tomcat 4.
    Regard Dietmar

  • Generate hierarchical xml data with xmlutilities ?

    hello
    I am just experimenting with the oracle xml utilities, because I
    want to set on http-services to access to our patient database.
    Is it possible to generate the following xml structure (ALL
    relevant diagnoses are hierarchically subordered to the ONE
    patient) when two tables (master table patient, dependent table
    diagnoses) are given ?
    <rowset>
    <row num=...>
    <name>smith</name>
    <diagnosis>
    <date> ...</date>
    <icd-code> ... </icd-code>
    <text> ... </text>
    </diagnosis>
    /*ev.further diagnosis*/
    </row>
    /*ev.further rows for further patients*/
    </rowset>
    By the moment, I have the impression that only list-similar xml
    data is possible.
    Thank You very much for comments.
    ali gerhard
    null

    Hi ali,
    Yes, you can use the CAST(MULTISET()) operator to create a
    nested table of subordered diagnostic record and display it.
    (You need the objects option installed if you are using 8.0.
    With 8i, the objects options is included free)
    e.g.
    /* Create a regular type */
    CREATE TYPE diagnostic_type AS OBJECt
    diag_date NUMBER,
    icd_code NUMBER,
    /* etc... all the necessary diagnostic details.. */
    /* create a nested table type */
    CREATE TYPE diagnostic_list_t AS TABLE OF diagnostic_type;
    /* Now u can use this in any query */
    SELECT p.name AS name,
    CAST(MULTISET( SELECT d.diag_date, d.icd_code,...
    FROM diagnosis_table d
    WHERE d.patient_name = p.name)
    AS diagnostic_list_t) AS diagnosis
    FROM patient_table p;
    This query as u can see gets the name of the patient and then
    creates a nested table of diagnostic records for the patient.
    This assumes that for every patient there are more than 1
    diagnosis records.
    If you have only one diagnostic record per patient then u can
    simply write this as,
    SELECT p.name AS name,
    diagnostic_t(d.diag_date,d.icd_code,...) AS diagnosis
    FROM patient_table p, diagnostic_table d
    WHERE p.name = d.patient_name;
    Here u are just constructing a structured diagnosis type from
    the given values.
    Hope this helps,
    Murali
    ali gerhard (guest) wrote:
    : hello
    : I am just experimenting with the oracle xml utilities, because
    I
    : want to set on http-services to access to our patient
    database.
    : Is it possible to generate the following xml structure (ALL
    : relevant diagnoses are hierarchically subordered to the ONE
    : patient) when two tables (master table patient, dependent
    table
    : diagnoses) are given ?
    : <rowset>
    : <row num=...>
    : <name>smith</name>
    : <diagnosis>
    : <date> ...</date>
    : <icd-code> ... </icd-code>
    : <text> ... </text>
    : </diagnosis>
    : /*ev.further diagnosis*/
    : </row>
    : /*ev.further rows for further patients*/
    : </rowset>
    : By the moment, I have the impression that only list-similar
    xml
    : data is possible.
    : Thank You very much for comments.
    : ali gerhard
    null

  • Problem in mapping xml data with header details from IPM 11g to BPEL

    Hi,
    I want to map xml data as a supporting content from IPM application to BPEL.
    My xml is
    <?xml version="1.0" encoding="utf-8"?>
    <DocumentFile xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/Document.xsd">
    <Document DocumentType="Invoice">
    <DocumentImage>
    <Filename>\\10.205.0.209\Img\10883212.TIF</Filename>
    </DocumentImage>
    </DocumentFile>
    If I remove header details from root element <DocumentFile> i.e. modified xml is
    <DocumentFile>
    <Document DocumentType="Invoice">
    <DocumentImage>
    <Filename>\\10.205.0.209\Img\10883212.TIF</Filename>
    </DocumentImage>
    </DocumentFile>
    it works fine but i need to pass header details as well.
    Please suggest.
    Thanks,
    Priya

    Hi Naveen,
    In sxmb_moni the content transmitted to the adapter(RFC)is as follows
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    - <RECORDS>
    - <item>
      <FLOC>f1-01-01</FLOC>
      <RFID_NO>I006</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-02</FLOC>
      <RFID_NO>I002</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-03</FLOC>
      <RFID_NO>I003</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-04</FLOC>
      <RFID_NO>I004</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-05</FLOC>
      <RFID_NO>I005</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-06</FLOC>
      <RFID_NO>I001</RFID_NO>
      </item>
      </RECORDS>
      </ns:ZRFID_EQUIP>
    At r/3 side the field floc and rfid_no gets mapped to floc which is of char30
    eg floc=f1-01-01I006
       rfid_no=

  • Singing XML Data with PKCS#7 with SHA1withRSA

    Dear All
    I am using the following code to sign xml message with PKCS#7 with SHA1withRSA. But I am facing bad signature error from the server, they are telling me that this is signed correctly.
    Please can anybody give some idea that i doing correctly as PKCS#7 with SHA1 algorithm.
    I am using bouncy castle libraries
      private byte[] sign(String input) {
            Security.addProvider(new BouncyCastleProvider());
            byte[] encoded = null;
            try {
                KeyStore keystore = loadKeyStore();
                Certificate[] certchain =
                    (Certificate[])keystore.getCertificateChain(MaadenPropertiesConstants.KEYSTORE_Alias);
                final List<Certificate> certlist = new ArrayList<Certificate>();
                for (int i = 0, length = certchain == null ? 0 : certchain.length;
                     i < length; i++) {
                    certlist.add(certchain[i]);
                PrivateKey key =
                    (PrivateKey)(keystore.getKey(MaadenPropertiesConstants.KEYSTORE_Alias, MaadenPropertiesConstants.KEYSTORE_PWD.toCharArray()));
                ContentSigner signer =
                    new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(key);
                CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
                generator.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()).build(signer,
                                                                                                                                                             (X509Certificate)keystore.getCertificate(MaadenPropertiesConstants.KEYSTORE_Alias)));
                generator.addCertificates(new JcaCertStore(certlist));
    //            CMSSignedData signedData =
    //            generator.generate(new CMSProcessableFile(new File(this.inputFile)),
    //                                   true); //changed to false
                CMSTypedData msg;
                msg = new CMSProcessableByteArray(input.getBytes());
                CMSSignedData signedData = generator.generate(msg, true);
                encoded = signedData.getEncoded();
                System.out.println("Got encoded pkcs7 bytes " + encoded.length +
                                   " bytes");
            } catch (Exception e) {
                e.printStackTrace();
            return encoded;
        private static KeyStore loadKeyStore() throws Exception {
            KeyStore keystore =
                KeyStore.getInstance(MaadenPropertiesConstants.KEYSTORE_INSTANCE);
            InputStream is =
                new FileInputStream(MaadenPropertiesConstants.keystoreLocation);
            keystore.load(is,
                          MaadenPropertiesConstants.KEYSTORE_PWD.toCharArray());
            return keystore;

    Dear All
    I am using the following code to sign xml message with PKCS#7 with SHA1withRSA. But I am facing bad signature error from the server, they are telling me that this is signed correctly.
    Please can anybody give some idea that i doing correctly as PKCS#7 with SHA1 algorithm.
    I am using bouncy castle libraries
      private byte[] sign(String input) {
            Security.addProvider(new BouncyCastleProvider());
            byte[] encoded = null;
            try {
                KeyStore keystore = loadKeyStore();
                Certificate[] certchain =
                    (Certificate[])keystore.getCertificateChain(MaadenPropertiesConstants.KEYSTORE_Alias);
                final List<Certificate> certlist = new ArrayList<Certificate>();
                for (int i = 0, length = certchain == null ? 0 : certchain.length;
                     i < length; i++) {
                    certlist.add(certchain[i]);
                PrivateKey key =
                    (PrivateKey)(keystore.getKey(MaadenPropertiesConstants.KEYSTORE_Alias, MaadenPropertiesConstants.KEYSTORE_PWD.toCharArray()));
                ContentSigner signer =
                    new JcaContentSignerBuilder("SHA1withRSA").setProvider("BC").build(key);
                CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
                generator.addSignerInfoGenerator(new JcaSignerInfoGeneratorBuilder(new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()).build(signer,
                                                                                                                                                             (X509Certificate)keystore.getCertificate(MaadenPropertiesConstants.KEYSTORE_Alias)));
                generator.addCertificates(new JcaCertStore(certlist));
    //            CMSSignedData signedData =
    //            generator.generate(new CMSProcessableFile(new File(this.inputFile)),
    //                                   true); //changed to false
                CMSTypedData msg;
                msg = new CMSProcessableByteArray(input.getBytes());
                CMSSignedData signedData = generator.generate(msg, true);
                encoded = signedData.getEncoded();
                System.out.println("Got encoded pkcs7 bytes " + encoded.length +
                                   " bytes");
            } catch (Exception e) {
                e.printStackTrace();
            return encoded;
        private static KeyStore loadKeyStore() throws Exception {
            KeyStore keystore =
                KeyStore.getInstance(MaadenPropertiesConstants.KEYSTORE_INSTANCE);
            InputStream is =
                new FileInputStream(MaadenPropertiesConstants.keystoreLocation);
            keystore.load(is,
                          MaadenPropertiesConstants.KEYSTORE_PWD.toCharArray());
            return keystore;

  • Delete XML nodes with E4X

    I trying to delete all the node from a XML that doesn't match some values.
    <Data>
         <Type id="1">
              <Details id="1">
                   <Products id="1">
                        <Value>123</Value>
                   </Products>
              </Details>
              <Details id="2">
                   <Products id="2">
                        <Value>123</Value>
                   </Products>
              </Details>
              <Details id="1">
                   <Products id="3">
                        <Value>123</Value>
                   </Products>
              </Details>
         </tType>
         <Type id="2">
              <Details id="1">
                   <Products id="1">
                        <Value>123</Value>
                   </Products>
              </Details>
              <Details id="2">
                   <Products id="2">
                        <Value>123</Value>
                   </Products>
              </Details>
         </Type>
    </Data>;
    Let's suppose I want to delete all the nodes "Details" where id == 1.
    I tried something like:
    delete xml..Details.(@id == 1);
    But this gives me and error...
    TypeError: Error #1119: Delete operator is not supported with operand of type XMLList
    So I tried:
    = 1);
    delete xml..Details.(@id == 1)[0];
    But this produces the following result (what makes some sense, since I passed only index 0).
    <Data>
      <ClientType id="1">
        <Details id="2">
          <Products id="2">
            <Value>123</Value>
          </Products>
        </Details>
        <Details id="1">
          <Products id="3">
            <Value>123</Value>
          </Products>
        </Details>
      </ClientType>
      <ClientType id="2">
        <Details id="1">
          <Products id="1">
            <Value>123</Value>
          </Products>
        </Details>
        <Details id="3">
          <Products id="2">
            <Value>123</Value>
          </Products>
        </Details>
      </ClientType>
    </Data>
    Only the first match is delete and not all the nodes.
    Can someone help on this one?
    thank you.

    Ok, I tried something and It works...
    while(xml..Details.(@id == 1).length() > 0)
        delete xml..Details.(@id == 1)[0];
    But, there's any direct solution to this? Only with E4X?

  • Problem in mapping xml data with imported RFC parameters

    I am currently working on a senario in which a flat file is generated by an RFID server and placed in FTP server.
    The flat file is picked up from the FTP server using XI and the contents are mapped to the corresponding imported RFC parameters.
    The content of the file which is in text format is successfully converted in XML at the XI side.
    File contains records of 2 fields Functional location and RFID equipment number . In the R/3 side these fields
    are used as Functional location and equipment number of PM module .
    The structure of the FTP message is as follows
    <ns:RFID_MSG_TYPE xmlns:ns="urn://sisl:rfiddemo">
    <RecordSet>
      <Row>
       <FL1>"f1</FL1>
       <FL2>01</FL2>
       <FL3>01</FL3>
       <RFID_NUM>I001"</RFID_NUM>
      </Row>
    </RecordSet>
    </ns:RFID_MSG_TYPE>
    After the mapping program which maps the above structure to the imported RFC is executed the following payload document is generated
    <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    <RECORDS>
      <item>
       <FLOC>f1-01-01</FLOC>
       <RFID_NO>I001</RFID_NO>
      </item>
    </RECORDS>
    </ns:ZRFID_EQUIP>
    The size of FLOC is 30 of type string and RFID_NO is also a string with size 18.
    When the data is brought in R/3 both the fields FLOC and RFID_NO gets mapped in FLOC which is of type char30.

    Hi Naveen,
    In sxmb_moni the content transmitted to the adapter(RFC)is as follows
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns:ZRFID_EQUIP xmlns:ns="urn:sap-com:document:sap:rfc:functions">
    - <RECORDS>
    - <item>
      <FLOC>f1-01-01</FLOC>
      <RFID_NO>I006</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-02</FLOC>
      <RFID_NO>I002</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-03</FLOC>
      <RFID_NO>I003</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-04</FLOC>
      <RFID_NO>I004</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-05</FLOC>
      <RFID_NO>I005</RFID_NO>
      </item>
    - <item>
      <FLOC>f1-01-06</FLOC>
      <RFID_NO>I001</RFID_NO>
      </item>
      </RECORDS>
      </ns:ZRFID_EQUIP>
    At r/3 side the field floc and rfid_no gets mapped to floc which is of char30
    eg floc=f1-01-01I006
       rfid_no=

  • How to Map XML data with XSD Schema in JAXB

    Hello,
    I am very much new to JAXB.
    I am in need of someone help to go further in my dev.
    I am having an XSD and i could able to do marshall and unmarshall using JAXB.
    My problem is...
    Consider followings are my Schema...
    - <person id="general" help="USER.DOM.HELP.GENERAL" label="USER.DOM.LABEL.GENERAL" access="READWRITE">
    <attribute id="Name" mandatory="true" type="STRING" access="READONLY" widget="NONE" />
    <attribute id="login" label="USER.LABEL.LOGIN" help="USER.HELP.LOGIN" regexp="[A-a]" type="STRING" summary="true" access="WCREATE_RUPDATE" widget="TEXTFIELD" />
    <attribute id="firstname" summary="true" label="USER.LABEL.FIRSTNAME" help="USER.HELP.FIRSTNAME" type="STRING" regexp="[A-a]" access="READWRITE" widget="TEXTFIELD" />
    In this example a person contains set of attributes... some are mandatory(Name)...
    In my application i will unmarshall the the schema file and show in GUI as a set of attributes when the operator want to create a person. And its very well working.
    Now say for example, i am requesting my server to show all the created persons and its showing. when i click on the particular person the GUI will place the request to the server to get the corresponding date for the selected person.
    But the response contains only the mandatory attribute.. i mean Name.... this may be because of the way my server working. So now i want to show the operator all the set of attributes for that person with the Name.
    I mean i need to merge the schema with me resultant data and show it in the GUI.
    My result is in the form of xml stream. And i will convert my schema also in the form of XML...
    Now i need to merge both of this XMl and need to present in the GUI...
    Any help please...
    Thank You!!!

    Still i am not getting any reply :(

  • Cannot view xml data with firefox, but other browsers can

    i cannot see xml based data in google-maps on one site :
    http://www.spotster.com/test_site/main_page.html
    but i can see it on the test site:
    http://www.zodiacinsight.com/index1.html
    and chrome browser sees the data in both sites...

    There may be a problem with that XML file, see the Tools > Error console
    *http://www.spotster.com/test_site/php/sortSpots.php
    <pre><nowiki>XML Parsing Error: not well-formed
    Location: http://www.spotster.com/test_site/php/sortSpots.php
    Line Number 66, Column 593:</nowiki></pre>

Maybe you are looking for