How to use XmlModify to sort the XML Data?

Hello,
I saw some examples explain how to use XmlModify in BDB XML package. I want to sort the XML data by several elements but my Java program could not work correctly.
<CustomerData>
<Transaction>
<DLSFIELDS>
<ADR_PST_CD>12345</ADR_PST_CD>
<CLT_IRD_NBR>002</CLT_IRD_NBR>
</DLSFIELDS>
</Transaction>
<Transaction>
<DLSFIELDS>
<ADR_PST_CD>12345</ADR_PST_CD>
<CLT_IRD_NBR>102</CLT_IRD_NBR>
</DLSFIELDS>
</Transaction>
// many nodes like transaction ...
</CustomerData>
My XQuery script was executed successfully in the shell. The script looks as follows:
"for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD), xs:decimal($i//CLT_IRD_NBR) return $i".
The Java code :
// create XmlManager
XmlManager manager = // ...;
// open XmlContainer
XmlContainer container = // ...;
XmlQueryContext context = manager.createQueryContext(XmlQueryContext.LiveValues, XmlQueryContext.Eager);
XmlQueryExpression expression = manager.prepare("for $i in collection('sample.dbxml')/CustomerData/Transaction order by xs:decimal($i//ADR_PST_CD),xs:decimal($i//CLT_IRD_NBR) return $i", context);
XmlModify modify = manager.createModify();
XmlUpdateContext uc = manager.createUpdateContext();
XmlDocument xmldoc = container.getDocument("sample.xml");
XmlValue value = new XmlValue(xmldoc);
long numMod = modify.execute(value, context, uc);
System.out.println("Peformed " + numMod     + " modification operations");
Could you point out the errors above or offer some suggestion?
Thanks.

I have other question of the sorting issue. Here are a large XML need to sort so I have to split it to multiple small XML files. After importing these files, I will use the XmlModify and XQuery to sort them. I'm not clear on the multiple XML files processing.
1. Can the BDB XML ensure that all these XML files were sorted or how to update all documents with same logic.
2. If I want export all these sorted documents, how can I ensure these files processed in sequence? Which document needs process first?
The export method:
public void export(String outputfile)throws Exception{
final int BLOCK_SIZE = 5 * 1024 * 1024; // 5Mb
try{
File theFile = new File(outputfile);
FileOutputStream fos = new FileOutputStream(theFile);
byte[] buff= new byte[BLOCK_SIZE];                         
XmlResults rs = container.getAllDocuments(new XmlDocumentConfig());               
while(rs.hasNext()){
     XmlDocument xmlDoc = rs.next().asDocument();
     XmlInputStream inputStream = xmlDoc.getContentAsXmlInputStream();                    
     long read=0;
     while(true){
     read = inputStream.readBytes(buff, BLOCK_SIZE);
fos.write(buff,0,(int)read);                    
     if(read < BLOCK_SIZE) break;
inputStream.delete();
xmlDoc.delete();
rs.delete();
//MUST CLOSE!
fos.close();               
catch(Exception e){
System.err.println("Error exporting file from container " + container);
System.err.println(" Message: " + e.getMessage());
Thanks.

Similar Messages

  • How to use JMF to play the video data in a array(not in a local file)?

    dear all:
    I am a newer to JMF.
    Now My program has a thread which is always inputing mpg video data into a static array, so I want to wrap this array as a DataSource, then let the player play the video.
    But I don't know how to wrap that as a DataSource, What I know is just play a media file.
    So could any guy give me some advice??
    Really appreciate your help!
    Thanks
    Sam
    MSN: [email protected]
    Email: [email protected]

    I have never tried doing what you are soing so I am just thinking aloud. I think that using datamerge for this is going to assign the same ID to the fields, which is why the checkboxes are filling when selecting one of them. Open the PDF in Acrobat to check it though.
    Another thought. Are you merging to a new document or direct to PDF? If going direct to PDF, try creating the merge document first. If that doesn't work, I think it will be the field IDs being also replicated. If so, then the only course of action would be either manually changing them in Acrobat, or an ID script and or an Acrobat script. Neither of which I have heard of. But if they do have the same IDs, then I would inquire in both the ID scripting forum and the Acrobat forum.
    Good luck. Interesting use of datamerge. I hope you find a suitable answer.
    Mike

  • How to use Xerces to validate an XML file against a DTD

    Hi, can anybody tell me how to use Xerces to validate an XML file against a DTD. its urgent. post some sample code. it would be helpful for my project. isupposed to use SAX parser(Xerces)
    Thanx in advance

    Come on, I googled "xerces validate" and the first link is the Xerces FAQ:
    http://xerces.apache.org/xerces-j/faq-general.html
    And of course "how to validate" is a Xerces FAQ. Help yourself by doing a little research instead of waiting for other people.

  • How do I use AppleScript to Change the Creation Date to the Current Date?

    I sorted my downloads folder by creation date and found that the items were sorted seemingly randomly. On closer inspection, I saw that the creation dates were not the same as the dates that I downloaded the items, so I figures that Snow Leopard was using the date given to it by the server.
    In order to get the items sorted by download date, I figured I'd use Hazel, but it doesn't have a “change creation date” item. It does, however, have an “run AppleScript” item.
    So my question is this: how do I use AppleScript to change the creation date of an item to the current date?

    TC (Techno Cat) wrote:
    Okay, I tried changing the creation date with SetFile, but it kept giving me an error:
    What am I doing wrong?
    Looks like the date and time was not quoted
    Try this Applescript. It will change the creation date of every file in the Downloads folder to the current date and time:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    font-weight: normal;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #E6E6EE;
    overflow: auto;"
    title="this text can be pasted into the AppleScript Editor">
    set current_date_and_time to do shell script "date \"+%m/%d/%Y %H:%M\""
    tell application "Finder"
    set filelist to every file of the alias (the path to downloads folder as text)
    repeat with currentFile in filelist
    do shell script "/usr/bin/SetFile -d " & quoted form of current_date_and_time & space & quoted form of POSIX path of (currentFile as string)
    end repeat
    end tell</pre>

  • How to store the XML data? file or database?

    i'm frustrate at it.
    If store XML data into files, then when i query any data,how can i search data using relationship as SQL?
    But if store XML data into database.How can i transform the xml data to the data table?
    Can any one give me an clear example.

    XML is perfect for data interchange and readability. However, to make it searchable you should resolve it properly into tables, in accordance of your own choice of model.
    1. Investigate the XML files and resolve the model
    <Person sex="male">John
    <Pet animal="dog">Doggy</Pet>
    <Pet animal="cat">Catty</Pet>
    </Person>
    2. Create the tables in your database, let one or several tables keep the raw xml for retrieval of original xml data.
    --- XMLDocument ---
    id XML_data
    --- Person ---
    id XML_Document_id sex name
    (foreign key)
    --- Pet ---
    id Person_id animal name
    (foreign key)
    3. Resolve data from the xml files and insert it into the database. Do this through your ContentHandler, or from your DOM model.
    --- XMLDocument ---
    id XML_data
    0 <Person>...</Person>
    --- Person ---
    id XML_Document_id sex name
    0 0 male John
    --- Pet ---
    id Person_id animal name
    0 0 dog Doggy
    1 0 cat Catty
    Gil

  • Reg :  vo.writeXML() how to filter the data before generating the xml data

    Hi team,
    I have table region with multi selection option.
    My requirement is to fetch the data and generate the xml data for the selected rows.
    By using : writeXML() --> it is fetching all the data.
    What are the methods i need to use,so i can fetch only the selected data ?
    Any pointers ?
    -Sridhar

    Hi Peddi,
    i tried the way u mentioned :
    But the new VO2 (Target) VO is having an extra row, iam not understanding how that is getting stored in VO2.
    Can you please review the below query and let me know if any issue.
    public void copyVO()
    int rowCount=0 ;
    OAFXMLVOImpl vo1 = getOAFXMLVO1(); //source
    OAFXMLVOImpl vo2 = getOAFXMLVO2(); //destination
    OAFXMLVORowImpl row2= null ;
    OAFXMLVORowImpl row1 =null;
    if(vo2!=null && vo2.hasNext())
    { vo2.first();
    do
    vo2.getCurrentRow().remove();
    vo2.next();
    while (vo2.hasNext());
    oracle.jbo.Row[] rows = (oracle.jbo.Row[]) vo1.getFilteredRows("check", "Y");
    rowCount = rows.length;
    if(rowCount>0)
    vo2.setMaxFetchSize(0);
    for(int i=0;i<rowCount;i++)
    row1 = (OAFXMLVORowImpl)rows;
    System.out.println("User ID-->"+ row1.getUserId());
    System.out.println("Checked -->"+ row1.getcheck() );
    row2 = (OAFXMLVORowImpl) vo2.createRow();
    row2.setUserId(row1.getUserId());
    row2.setcheck(row1.getcheck());
    vo2.insertRow(row2);
    row2.setNewRowState(row2.STATUS_INITIALIZED);
    } //end of if
    -Sridhar

  • How to use XMLEncoder to save Complicated XML??

    I think I posted in an improper forum: java programming, so repost here. Please excuse me.
    Dear friends, good weekend and happy thanksgivings.
    I met a problem when I use XMLEncoder to generate a complicated XML like following:
    <?xml version="1.0"?>
    <messages>
      <note ID="501">
        <to>Tove</to>
         <DeliveryAddress>
              <Street>12345</Street>
              <City>Parsinpany</City>
              <County>ABC</County>
              <State>NJ</State>
              <Country>USA</Country>
             </DeliveryAddress>
         <ContactID>
              <CompanyID>
                   <Address>12345</Address>
                   <City>Alnomre</City>
                   <County>BBB</County>
                   <State>TX</State>
                   <Country>USA</Country>
                  </CompanyID>
              <phone>1800-1234567</phone>
              <fax>123-456-7890</fax>
             </ContactID>
        <from>Jani</from>
        <heading>Reminder</heading>
        <body>Don't forget me this weekend!</body>
      </note>
      <note ID="502">
        <to>Jani</to>
        <from>Tove</from>
        <heading>Re: Reminder</heading>
        <body>I will not!</body>
      </note>
    </messages>How to use XMLEncoder to generate abobe XML or one that has namespaces in it??
    I can use simple
    XMLEncoder o = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(filename)));
                                  o.writeObject(mm.getBounds());     //get all position;
    but cannot generate above complicated XML.
    What is the right way to do it??
    any good example??
    Thanks

    My question is also how to use XMLEncoder to create attributes and and namespace, add child nodes to its parent, or remove nodes from their parent etc
    Thanks

  • Any one knows how to use Axis Framework in the SOAP Adapter Modules

    How to use Axis Framework in the SOAP Adapter?
    How to add custom handler modules?
    http://help.sap.com/saphelp_nw04/helpdata/en/45/a4f8bbdfdc0d36e10000000a114a6b/frameset.htm
    I went through the above link on help.sap.com. But still could not create a working example.
    I have created a wc on some 3ed party app server using apaches axis. I am trying to call that web service from XI using SOAP receiver? I need to add some security related headers to the soap message, SO I am trying to use a handler.  I want to know how to configure this handler in SOAP axis adapter module.
    Thank you
    Moni

    Ravi ,
    I am trying exactly the same. Hers is the scenario.
    ABAP Proxy --> PI (7.0) SP 12 ---> WebService.
    Since This is service is secured, means it is using OASIS web servie securyty user name token,
    I am trying to use AXIS adapter. and I want to configure HandlerBean in which I want to use apache wss4j api to add the userNameToken. I am looking for some documentation on this.
    I need to add SOAP action element too as I can not configure this one on the communication channel.
    Thanks for any inputs in this regard.
    Moni

  • How to use bind variables in the following query

    CREATE OR REPLACE PROCEDURE MMDB.test IS
    sel_qtn VARCHAR2 (10);
    CURSOR PT_QUANTITY IS select * from mmdb.product_tree WHERE QUANTITY_CHECK ='E'
    AND run_id = 100
    a PT_QUANTITY%ROWTYPE;
    BEGIN
    FOR i IN PT_QUANTITY
    loop
    sel_qtn := i.quanttity-1;
    While sel_qtn>=1
    loop
    insert into mmdb.product_tree (BILLING_ACCOUNT_NO ,S_CODE) values (i.BILLING_ACCOUNT_NO ,i.S_CODE||'E');
    sel_qtn :=sel_qtn -1;
    End loop;
    commit;
    end;

    Don't duplicate threads: How to use bind variables in the following query

  • How to use SQL functions in the queries

    hey guys i wanna know how to use SQL functions in the queries is it possible or not .

    Hi,
    Wat exactly that set values are?
    those from sql query?
    How to use count():
    The COUNT() function returns the number of rows that matches a specified criteria.
    SQL COUNT(column_name) Syntax
    The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:
    SELECT COUNT(column_name) FROM table_name
    SQL COUNT(*) Syntax
    The COUNT(*) function returns the number of records in a table:
    SELECT COUNT(*) FROM table_name
    SQL COUNT(DISTINCT column_name) Syntax
    The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column:
    SELECT COUNT(DISTINCT column_name) FROM table_name
    The IN function helps reduce the need to use multiple OR conditions.
    The syntax for the IN function is:
    SELECT columns
    FROM tables
    WHERE column1 in (value1, value2, .... value_n);

  • [Forum FAQ] How to use parameter to control the Expand/Collapse drill-down options in SSRS report?

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

    In SQL Server Reporting Services (SSRS), drill-down is an action we can apply to any report item to hide and show other report items. They all are ways that we can organize and display data to help our users understand our report better. In this article,
    we are talking about how to use parameter to control the Expand/Collapse drill-down options in SSRS report.
    Consider that the report has a dataset (dsSales) with following fields: SalesTerritoryGroup, SalesTerritoryCountry, CalendarYear, SalesAmount.
    1. The report has the following group settings:
    Parent Group: SalesTerritoryGroup
     Child Group: SalesTerritoryCountry
      Child Group: CalendarYear
       Details: SalesAmount
    2. Add three parameters in the report:
    GroupExpand:
    Available Values: “Specify values”
    Label: Yes           Value: Yes
    Label: No            Value: No
    Default Values: “Specify values”
    Value: Yes
    CountryExpand:
    Available Values: “Specify values”
    Label: Yes           Value: =IIF(Parameters!GroupExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No","No","Yes")
    YearExpand:
    Available Values: “Specify values”
    Label: Yes          
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No",Nothing,"Yes")
    Label: No            Value: No
    Default Values: “Specify values”
    Value: =IIF(Parameters!GroupExpand.Value="No" or Parameters!CountryExpand.Value="No","No","Yes")
    3. Right click SalesTerritoryCountry icon in the Row Groups dialog box, select Group Properties.
    4. Click Visibility in the left pane. Select “Show or hide based on an expression” and type with following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", False, True)
    Select “Display can be toggled by this report item” option, and select “SalesTerritoryGroup” in the drop down list.
    5. Use the same method setting CalendarYear, (Details) drill-down with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", False, True)
    =IIF(Parameters!YearExpand.Value="Yes", False, True)
    6. Click SalesTerritoryGroup text box in the tablix. Select InitialToggleState property in the Properties dialog box, and type following expression:
    =IIF(Parameters!GroupExpand.Value="Yes", True, False)
    7. Use the same method setting SalesTerritoryCountry, CalendarYear text box with following expression:
    =IIF(Parameters!CountryExpand.Value="Yes", True, False)
    =IIF(Parameters!YearExpand.Value="Yes", True, False)
    After that, when we preview the report, we can use these three parameters to expand/collapse drill-down.
    Note:
    In our test, we may meet following issue. We can check the expression of InitialToggleState property to troubleshooting the issue.
    Applies to
    Reporting Services 2008
    Reporting Services 2008 R2
    Reporting Services 2012

  • I need to program a Hittite Fractional​-N Synthesize​r Evaluation Kit with a HMC702LP6C​E an external YIG oscillator​. Not sure how to use Labview to control the PLL.

    I need to program a Hittite Fractional-N Synthesizer Evaluation Kit with a HMC702LP6CE an external YIG oscillator.  Not sure how to use Labview to control the PLL.

    Here is how to use the PLL. But I don't know of how to interact with that device
    http://zone.ni.com/devzone/cda/tut/p/id/3781
    And for thouse who don't know what a PLL is a free bonus link is here:
    http://digital.ni.com/public.nsf/allkb/07BC8D77D4E​9AE258625708B007CE74F?OpenDocument
    and a second one on what that device is: http://www.hittite.com/products/view.html/view/HMC​702LP6CE
    Now we are all caught up to speed.
    Sam S
    Applications Engineer
    National Instruments

  • How to use bexweb analyser in the webbrowser

    Hi ALL,
    Suggest me .how to use bexweb analyser in the webbrowser?
    Regards,
    Suman

    Hi,
    A useful link for you..!!
    http://help.sap.com/saphelp_nw04s/helpdata/en/0d/af12403dbedd5fe10000000a155106/frameset.htm
    -Pradnya

  • How to use application item in the page template

    How to use application item in the page template.
    Thanks,
    rajendra

    Hi,
    You can refer application item value in template like &MY_ITEM. (note period at end)
    http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35125/concept_sub.htm
    Regards,
    Jari

  • How to fetch the xml data in webdynpro java

    Hi all,
    i have an xml data which contains the fields as 1.user type, 2. client, 3.vendor number
    in webdynpro java how i validate or fetch the details of  the user type, when ever user login's in portal i can show some data to user 'A' and invisible to user 'B', based on the xml data.
    help me in doing step by step'
    Thanks&Regards
    charan

    Hi
    Follow the steps .
    This is the XML file .
    <?xml version="1.0"?>
    <company>
         <employee>
              <firstname>Tom</firstname>
              <lastname>Cruise</lastname>
         </employee>
         <employee>
              <firstname>Paul</firstname>
              <lastname>Enderson</lastname>
         </employee>
         <employee>
              <firstname>George</firstname>
              <lastname>Bush</lastname>
         </employee>
    </company>
    Java Code of this to fetch the details.
    public class XMLReader {
    public static void main(String argv[]) {
      try {
      File file = new File("c:\\MyXMLFile.xml");
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(file);
      doc.getDocumentElement().normalize();
      System.out.println("Root element " + doc.getDocumentElement().getNodeName());
      NodeList nodeLst = doc.getElementsByTagName("employee");
      System.out.println("Information of all employees");
      for (int s = 0; s < nodeLst.getLength(); s++) {
        Node fstNode = nodeLst.item(s);
        if (fstNode.getNodeType() == Node.ELEMENT_NODE) {
               Element fstElmnt = (Element) fstNode;
          NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("firstname");
          Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
          NodeList fstNm = fstNmElmnt.getChildNodes();
          System.out.println("First Name : "  + ((Node) fstNm.item(0)).getNodeValue());
          NodeList lstNmElmntLst = fstElmnt.getElementsByTagName("lastname");
          Element lstNmElmnt = (Element) lstNmElmntLst.item(0);
          NodeList lstNm = lstNmElmnt.getChildNodes();
          System.out.println("Last Name : " + ((Node) lstNm.item(0)).getNodeValue());
      } catch (Exception e) {
        e.printStackTrace();
    BR
    Satish Kumar

Maybe you are looking for