Put ID attributes on all nodes

Hello
I have an XML similar to this
<root>
<elem>
<subElem>
</subElem>
</elem>
<elem>
<subElem>
</subElem>
<subElem>
</subElem>
</elem>
</root>
I'm trying to put a lot of "Id" attributes on each element for easy acces. I want a result like
<root>
<elem id="1">
<subElem id="1">
</subElem>
</elem>
<elem id="2">
<subElem id="1">
</subElem>
<subElem id="2">
</subElem>
</elem>
</root>
So I can acces the second "sub" in the second element as /root/elem/@id="2"/sub/@id="2"
Do you have any way to put that "Id" attributes using XQuery or another way. I prefer a non programmatic method (that is, using Oracle, not Java).
I've tried with InsertChildXML function in this way
update xmlTable
set xmlField = insertChildXML (xmlField, '/root//*','@id','nothing');
That works, but, how I can put the Id numbers for each element and subelement?
Another way is using XQuery, but at now, I'm getting poor results.
Any help?
Thanks.
José Domingo Hernández
Edited by: jdhernandez on Sep 2, 2009 8:28 AM

Without knowing all the details of why you are trying to add an id attribute, beyond "easy access", why not just use an XPath like
/root/elem[2]/subElem[2]
instead of
/root/elem/@id="2"/sub/@id="2"
Using either XML, my Xpath says to get the second subElem within the second elem within the root node. This agrees with what yours asks for, on the assumption that nothing reorders the XML during your processing.

Similar Messages

  • Image field - cannot set h and w attribute of all node elements

    Hi guys,
    We currently need to show some photos on our .pdf forms when the form is generated.  The number of pictures are unknown at runtime and need to be determined dynamically.  This is not the problem - we figgured this out by using base64 encoding for retrieving these picture.
    Now, when we try to display all of these picures on the .pds we would like to have control over the width and size of these pictures ( the h and w properties.). The problem is that only the VERY FIRST picture gets applied these properties that we set, and all the following pictures are the size as per design time.
    This is obviously do to us not knowing how to "loop through" this node in JavaScript/FormCalc.  Please help!  Also, which event should we use?
    This is the code we are using:
    xfa.form.pdfFields.Notification.SubformPhoto.Table9.Row1.ImageField2.h
    = "4in";xfa.form.pdfFields.Notification.SubformPhoto.Table9.Row1.ImageField2.w
    = "4in";
    We thought that the following should work to apply the values for all the elements, but this does not work.
    xfa.form.pdfFields.Notification.SubformPhoto.Table9.Row1.ImageField2[*].h = "4in";xfa.form.pdfFields.Notification.SubformPhoto.Table9.Row1.ImageField2[
    *].w = "4in";
    Thanks!

    Hi,
    I don't know want you want to do with
    Method[] methods = element.getClass().getMethods();
    If you just want to set the values in the Context you can just go for using:
    wdContext.currentUserElement().setPassword("VALUE");
    wdContext.currentUserElement().setName("VALUE");
    Or If you have a collection you can create elements in a loop like
    you posted in the beginning of this thread:
    IPrivateUserView.IUserElement element = wdContext.nodeUser().createUserElement();
    wdContext.nodeUser().addElement(element);
    element.setUserName("VALUE");
    element.setUserPassword("VALUE");
    Regards,
    Dennis

  • How can I add an attribute to a node?

    Hi,
    How can I add an attribute to a node of a DOM Document?
    I want to add attribute Maximum="6" for all Grade node as <Grade Maximum="6">.
    Grade is a third level node in my document.
    Thanks

    Hi,
    How can I add an attribute to a node of a DOM
    Document?
    I want to add attribute Maximum="6" for all Grade node
    as <Grade Maximum="6">.
    Grade is a third level node in my document.
    ThanksGet the father of "Grade" elements as an element. Then get all elements named "Grade", and for each one set attribute "Maximum" with value "6". If you read api documentation you will know which methods to use.
    But for helping you in getting the "Grade" parent.
    1) get the root element of the Dom Doc
    2)get the father of the "Grade" father: getElementsBytagName("his name") -> it will return a Node List get the first element casting as Element if there's only one, or elese if not case
    3)the same method in 2 get the "Grade" father
    4)getElementByTagName("Grade") over the "Grade" father -> for each "grade" element on nodelist do whatever you need
    i hope u understood...

  • How can i put an attribute in a message part?

    Hi all,
    i need to put an attribute in a message part. Now my message-declaration looks like this:
    <wsdl:message name="GetCapabilitiesIn">
    <wsdl:part name="GetCapabilities" type="xsd:string"/>
    </wsdl:message>
    and it generates this message:
    </GetCapabilities>
    But i need to generate this message:
    </GetCapabilities service="XYZ">
    How can i wangle that?
    thanks
    Alli

    the type should point to a complex type that can define elements and attribtues .. such as you are used to it ..
    so just create a complex type => that has your attributes in it, and replace the type="xsd:string" with your new complex type ..
    /clemens

  • How-to build a NodeList of ALL nodes in an XMLDocument

    Hello List,
    I am trying to write a method which takes in an XMLDocument and iterates over each element in the XMLDocument, extracting the value of an attribute, key, and using key to access a HashMap and add an important bit of data to the element.
    I am trying to use NodeList as the collection of elements but am having trouble getting either XMLNode.selectNodes(String pattern) or XMLNode.getChildNodes(String pattern) to return a NodeList containing ALL the nodes in the XMLDocument.
    Instead it is returning sibling nodes in its list, but not finding the children which these sibling nodes contain.
    Am I misuing the API? Is there another way to accomplish this?
    Any tips, suggestions, reponses, answers welcome.
    TIA,
    Alex Reuter

    Ok, here is how I am doing it.
    I am settling for a nodelist of all nodes which have attributes named key.
    XMLNode nodey = othernode;
    NodeList list = nodey.selectNodes("descendant::*/@key");
    just for posterity..
    alex

  • How to check that data was propagated to all nodes in cluster?

    Hi.
    We are using Weblogic 10.3.5 and Coherence 3.6. Both applications work in cluster mode and we are using replicated mode as a Coherence topology. Also the NameCache use to store and retreive data from Coherence cluster. Now I have a task to calculate a time that take data propagation to all nodes. So, from my sight of view coherence should raise some kind of event when each node in cluster will fulfield with the same data. Or may be there is a standard coherence(weblogic?) listener that provide such an information.
    I will be appreciate for help how to solve my task.

    Jonathan.Knight wrote:
    Hi,
    If you are using a replicated cache then the time taken to replicate the data is the time taken to do a put. Coherence will not return from a put method call on a NamedCache until the data has reached all the nodes. That is why replicated caches are a bad idea for clusters with a lot of nodes where there are frequent updates as they are slow.
    JKHi JK,
    actually, AFAIK, it is not 100% correct.
    From what I remember from an earlier discussion or email, replication in a replicated cache is synchronous to one other member (the lease owner), and asynchronous thereafter. The synchronous part of the protocol involves the mutating member and the entry lease owner (which may be the same). As I understand the lease owner orders the operations and resolves races between multiple mutators, and drives the asynchronous part of the replication to all other members.
    In short, total network cost is linear with nodes, but latency wise you do not need to wait until all updates actually took place on all other nodes (that would be a really sad scenario when some nodes are communicating slowly).
    Best regards,
    Robert

  • In history displays. put checkmarks and select all.

    In history displays. put checkmarks and select all.

    Can you clarify what you mean?
    Do you have a problem with the history?
    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    *Use a compressed image type like PNG or JPG to save the screenshot
    *Make sure that you do not exceed the maximum size of 1 MB

  • How can I instruct SqlMetal to exclude the 'storage' attribute of all the columns on a mapping file when converting a .dbml file to a mapping file?

    Hi,
    I'm trying to use LINQ to SQL with a top down approch using my own POCO classes. I'm using a XML file for the external mapping but in order to avoid typing a long file by hand I found that I could use the O/R designer to create the .dbml and from there I
    could use SqlMetal.exe to generate the map file from the .dbml. The only thing is that, by default, SqlMetal generates a map file which includes the 'storage' attribute for all the columns of the database. For example:
    <
    Column
    Name="Ticker"
    Member="Ticker"
    Storage="_Ticker"
    DbType="NChar(20)
    NOT NULL"
    CanBeNull="false"
    />
    However, in my code I only use automatic properties (Ticker, in this example) and not properties with the corresponding private field. Basically, I don't have any field "_Ticker" in my class. I found out that this the reason why I'm getting the error
    "Bad Storage property: '_Ticker' on member 'TTS.Domain.Asset.Ticker" when trying to add an entity to the database. However, ff I delete the all the 'storage' attributes from my mapping file everything works fine.
    Is there a way so I could use SqlMetal to generate a map file from a .dbml file but in which it never includes the 'storage' attribute?
    Thanks.
    Best,
    Miguel T.
    This is reason why I'm getting the error.

    Hi Serguey,
    I was expecting that answer but I still had some hope that it could be possible! I checked those 2 links before sending my question.
    Currently, I'm deleting the storage attributes everytime that I generate a mapping file. The issue is that I will have to do this eveytime that I need to add data in my O/R designer which happens quite frequently since I'm working with iterations in my project.
    It's not very practical but it's still better than write the additional data by hand.
    I don't know how I could create my own mapping validation in order to exclude the 'storage' attributes everytime that I generate a mapping file from a .dbml file with SqlMetal but I will check that option too.
    Thanks for your helps.
    Best,
    Miguel.

  • Get All Nodes in a tree

    Can somebody tell me how to get all the node objects (DefaultMutableTreeNode) that are there in JTree?
    Suppose I have created a tree and added 4 nodes to the same, and if I want to get dynamically all the nodes that are there in the tree, what should I do?
    Please help me..as it is urgent
    Thanx in Advance
    Novi

    If you check the documentation to DefaultMutableTreeNode you see that some methods return enumerations, for example postorderEnumeration. You can use these to traverse the tree,
    DefaultMutableTreeNode root = ....;         // start node.
    Enumeration e = root.postorderEnumeration(); // get wanted enumeration
    while (e.hasMoreElements()) {                // all nodes
       DefaultMutableTreeNode node =
          (DefaultMutableTreeNode)e.nextElement(); // get node
       // do something with the node
    }PS. The code compiles but I havent actually run it :(

  • How to get the name and value of an attribute on a node/element that is not a child

    Hello,
    Can someone shed some wisdom on how I can compare 2 xml nodes for differences.
    My main challenge is I need to use the attributes/values of 'ProductDescription' and 'Features' as 'key' to identify the same node in
    another doc with the same layout, but different content.
    I am having trouble getting the name of the attribute on the node, 'ProductDescription' and 'Features'.  I can only seem to get the node names, but not the attributes on the node.  I need the name, because it can be different from doc to doc, so
    I can't hardcode this.
    Can someone please help with how to retrieve an attribute name/value on a node that is not a child.  Here's an example of what
    my xml looks like:
    DECLARE
    @myDoc1 xml
    ,@mydoc2 xml
    DECLARE
    @ProdID int
    SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <features featureID = "2" featureName = "seat">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>
    SET @myDoc2 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>2 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <features featureID = "2" featureName = "wheel">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>
    I need to compare the attributes of 'ProductDescription' and 'Features' from @mydoc1 against @mydoc2 to see if they are the same based on those 2 nodes first.  If they are, then i want to show the difference in the child elements. 
    This will eventually be an outer join to give me the differences betw the 2 docs based on those key values (node attributes).
    I used node('//*') for the path, and value('local-name(../.)', 'varchar(50)') as element
    ,value('.[not(@xsi:nil = "true")]','VARCHAR(255)') AS new_value
    ...etc...
    but that only gives me the node names, and the child elements.  It does not give me back the attribute names and values from the node itself.
    Thanks in advance for your help.
    cee

    Are you looking for something like this:
    DECLARE @myDoc1 xml
    SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <Features featureID = "2" featureName = "seat">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>'
    SELECT T.c.value('local-name(.)', 'nvarchar(50)') AS name,
           T.c.value('.', 'nvarchar(50)')  AS value
    FROM   @myDoc1.nodes('ProductDescription/@*') AS T(c)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to access multiple attributes of a node at the same time in XML AS3

         <chapter id="1" title="">
         <screen title="lesson">
         <swf>EXCEL/CH01/CH01_S01.swf</swf>
         <ltitle>Chapter 1</ltitle>
         <rtitle>Setting Up a Workbook</rtitle>
         <prompt>Choose a lesson</prompt>
         </screen>
         <screen title="lesson" tasks="3">
         <swf>EXCEL/CH01/CH01_S02.swf</swf>
         <ltitle>Chapter 1</ltitle>
         <rtitle>Setting Up a Workbook</rtitle>
         <prompt>Click Next to continue</prompt>
         </screen>
    I have 2 attributes of screen node which are title and tasks.
    how can I access these 2 attributes at the same time in AS3
    Is that correct:
    excel.chapter.screen.(@title == "lesson").@tasks
    Thanks alot in advance.

    var excel:XML = <data>
    <chapter id="1" title=""> 
      <screen title="lesson" tasks="">
       <swf>EXCEL/CH01/CH01_S01.swf</swf>
       <ltitle>Chapter 1</ltitle>
       <rtitle>Setting Up a Workbook</rtitle>
       <prompt>Choose a lesson</prompt>
      </screen>
      <screen title="lesson" tasks="3">
       <swf>EXCEL/CH01/CH01_S02.swf</swf>
       <ltitle>Chapter 1</ltitle>
       <rtitle>Setting Up a Workbook</rtitle>
       <prompt>Click Next to continue</prompt>
      </screen>
    </chapter>
    </data>;
    trace(excel.chapter.screen.(@title == "lesson" && @tasks == "3").toXMLString());
    Note that for this to work (and not throw an error) every screen node needs a tasks attribute.
    In your sample code, the first screen node did not have a tasks attribute, in which case an error is thrown when using @tasks == "3"

  • How to find out the IP@s of all nodes in a cluster?

    Is there any way to retrieve the IP addresses of all nodes in a cluster?
    The problem is the following. We intend to write an administration program
    that administers all nodes of a cluster using rmi (e.g. tell all singletons
    in the cluster to reload configuration values etc.). My understanding is
    that rmi only talks to a single node in a cluster. It would be a convenient
    feature if the administration program could figure out all nodes in a
    cluster by itself and then administers each node sequentially. So far we're
    planning to pass all IP addresses to the administration program e.g. as
    command line arguments but what if a node gets left out due to human error?
    Thanks for your help.
    Bernie

    There is no public interface to inquire about the IP addresses of the servers in a cluster. If you use WLS 6.0, there is an administrative console that uses JMX to manage the cluster. Perhaps that would be of use to you?
    Bernhard Lenz wrote:
    Is there any way to retrieve the IP addresses of all nodes in a cluster?
    The problem is the following. We intend to write an administration program
    that administers all nodes of a cluster using rmi (e.g. tell all singletons
    in the cluster to reload configuration values etc.). My understanding is
    that rmi only talks to a single node in a cluster. It would be a convenient
    feature if the administration program could figure out all nodes in a
    cluster by itself and then administers each node sequentially. So far we're
    planning to pass all IP addresses to the administration program e.g. as
    command line arguments but what if a node gets left out due to human error?
    Thanks for your help.
    Bernie

  • Process XML attributes of all tables in a structured document

    Hi all,
    I try to process the XML attributes of all tables in a structured document.
    When I use SelectedTbl everything works fine for the selected table and the attributes of the tabelle Element are written correctly to the Console.
    doc = app.ActiveDoc;
    table = doc.SelectedTbl;
    if (table.TblElement)
        Console('Elementname: ' + table.TblElement.ElementDef.Name);
        tblEle = table.Element;
        attrs = tblEle.GetAttributes();
        for (i = 0; i < attrs.len; i++) {
            aName = attrs[i].name;
            aWert = attrs[i].values;
            Console( "     " + aName + "    " + aWert);     
    However when I use GetText(Constants.FTI_TblAnchor) to walk through all tables of the documens neither ElementDef.Name nor Attributes are processed.
    var flow = doc.FirstFlowInDoc;
    var textItems = flow.GetText(Constants.FTI_TblAnchor);
    while(iTab<textItems.length) {
    table = textItems[iTab].obj;
    if (table.TblElement)
        Console('Elementname: ' + table.TblElement.ElementDef.Name);
        tblEle = table.Element;
        attrs = tblEle.GetAttributes();
        for (i = 0; i < attrs.len; i++) {
            aName = attrs[i].name;
            aWert = attrs[i].values;
            Console( "     " + aName + "    " + aWert);     
    Any Suggestions?
    Yours
    Wolfgang

    You'll probably want all the tables from the main flow. Try
    var flow = doc.MainFlowInDoc;
    Kind regards
    JoH

  • How to make the times of all nodes similar

    Hi,
    i have a 3 node 10.2.0.4 64Bit Cluster database on
    HP Itanium with OS RHEL-4.6.
    we donot have any NTP Server integrated with these.
    Three nodes are running with three different Time with significant differences.
    More over 2 of the Nodes run well ahead of real Actual time and One run behind actual time.
    For Example at 11:34 AM the nodes return their times as follows::
    HOST_NAME DATETIME
    Node-1 11-JUL-2012 11:56:38
    HOST_NAME DATETIME
    Node-1 11-JUL-2012 11:18:12
    HOST_NAME DATETIME
    Node-3 11-JUL-2012 11:44:26
    the real time difference is 16 Min Minus and 22 Min Plus.
    And difference of Times does have an adverse business impact.
    if syncronization without NTP is possible -- that would be great.
    if not, how can we bring all the server nodes close to the real time.
    Your suggestion and workaround will be appreciated to synchronize the times of three instances
    as much possible with out hampering the Cluster Services.

    onedbguru wrote:
    I forget the name of it, but there is an executable that is used in Exadata clusters to do the same thing. Two standerd bash scripts I deploy to all RAC servers are called rac (for running a "RAC command" on all nodes) and raccp (for distributing a local file to all other RAC servers).
    Uses ssh and scp and are quite useful. Want to see uptime for example? rac uptime. Want to distribute the updated ntp config? raccp /etc/ntp.conf.
    Sadly though - no Exadata. There are 2 Exadata DB Machines in the corporate, but despite having one of the busiest databases on a self-build 12 node 3-yer old RAC, crunching data 24x7 for our corporate clients, no Exadata for us... Kind of like this Dilbert situation - total incompetence and requesting many millions are required.

  • How can i read Attributes from a Node

    Hi,
    I want to write parser to read my configuration file.
    here is my XML file:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!-- DOCTYPE Xportal SYSTEM ".\dtd\relation_config.DTD" -->
    <root>
    <value>25</value>
    <group type="Content Relation" color="255, 255, 255" active="1">
         <relationtype> DBNode - Document </relationtype>
    </group>
    <group type="Organisation Relation" color="255, 255, 255" active="1">
         <relationtype> Catalog - Document </relationtype>
         <relationtype> Documentversion - Documentvariant</relationtype>
    </group>
    <group type="Rights Relation" color="255, 255, 255" active="1">
         <relationtype> Catalog - Usergroup</relationtype>
         <relationtype> User - Usergroup </relationtype>
         <relationtype> User - Catalog </relationtype>
         <relationtype> Usergroup - Document </relationtype>
    </group>
    <group type="Desktop Organisation Relation" color="255, 255, 255" active="1">
         <relationtype> MatrixFolder - Document </relationtype>
    </group>
    <group type="System Organisation Relation" color="255, 255, 255" active="1">
         <relationtype> User - Session </relationtype>
    </group>
    <group type="Links Relation" color="255, 255, 255" active="1">
         <relationtype> DBNode - Linkimpl. </relationtype>
         <relationtype> Document - HyperlinkImpl. </relationtype>
         <relationtype> Document - Linkendimpl. </relationtype>
         <relationtype> Variante - Linkendimpl. </relationtype>
         <relationtype> Version - LinkendImpl. </relationtype>
         <relationtype> (ParentDB) - LinkendImpl. </relationtype>
    </group>
    <group type="Matrix Relation" color="255, 255, 255" active="1">
         <relationtype> Bla </relationtype>
         <relationtype> Blalbla </relationtype>
    </group>
    </root>
    and here my program:
    public class RelConfigReader {
    // c'tor
    public RelConfigReader() {}
    public void readConfig() {
    try {
    // Erstellen von DocumentBuilder
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    Document doc = docBuilder.parse(new File("relation_config.xml"));
    // normalize text representation
    doc.getDocumentElement().normalize();
    System.out.println("Root element of document is: " + doc.getDocumentElement().getNodeName());
    // Auslesen der Anzahl der Gruppen
    NodeList listOfGroups = doc.getElementsByTagName("group");
    int totalGroups = listOfGroups.getLength();
    System.out.println("Number of Groups : " + totalGroups);
    for (int s = 0; s < totalGroups; s++) {
    Node groupNode = listOfGroups.item(s);
    if (groupNode.getNodeType() == Node.ELEMENT_NODE) {
    System.out.println("Group " + s + ":");
    Element groupElement = (Element) groupNode;
    // Auslesen von Relation Typen
    NodeList relationTypList = groupElement.getElementsByTagName("relationtype");
    for (int i = 0; i < relationTypList.getLength(); i++) {
    Element relElement = (Element) relationTypList.item(i);
    NodeList textRelList = relElement.getChildNodes();
    System.out.println("Relationtype : " + ( (Node) textRelList.item(0)).getNodeValue().trim());
    catch (SAXParseException err) {
    System.out.println("** Parsing error" + ", line " + err.getLineNumber() + ", uri " + err.getSystemId());
    System.out.println(" " + err.getMessage());
    catch (SAXException e) {
    Exception x = e.getException();
    ( (x == null) ? e : x).printStackTrace();
    catch (Throwable t) {
    t.printStackTrace();
    now to my question. I have the <group> node with type, color and active as attribute of this node. Now i want to read this attributes but I don't know how I can do this. Please help me. Thx for any solution.

    I have the solution! Thx

Maybe you are looking for

  • Upload POST PL/SQL (gateway)

    I've managed to configure upload of documents via a web brower on a box running oracle 9i. It does the usual upload into a documents table (blob data). It is pretty much the same as the well published example given in metalink. I've been trying to re

  • Extended desktop iMac - Air

    Hello! I have iMac (Intel - Dual Core) and Macbook Air. Can you please tell me how can i connect them together to have extended desktop. Any help appriciated. Kind regards.

  • Clean install won't install Yosemite

    I'm attempting to install Yosemite on a clean slate. I've followed the instructions here: http://osxdaily.com/2014/10/18/clean-install-os-x-yosemite/ I'm at the point where I've got Yosemite on a thumb drive, I've held down option and I've erased the

  • Moving over to RBAC from responsibilities based model

    Hello, We are on 11.5.10 and are evaluating moving over to Role based, RBAC model for user management from the current responsibilities based model. We have a HRMS and Financials implementation. Would anybody have any pointers about any documentation

  • WARNING: Unable to cache frmrwinteg.jar

    I am seeing this warning message in my Java console. I am running 10g Forms and Reports. Here is my current dilemma - I am able to download 3rd party forms to a local drive, modify them, save and compile them, and then have my changes show up when I