Add attribute to a XML node at a specific position

I have this XML :
var myNode:XML = <node attribute="123"/>
I know how to add an attribute to the node :
myNode.@otherAttribute = "abc";
But this adds the attribute to the end. What if I want to add it as the first attribute ? I would like to have :
<node otherAttribute="abc" attribute="123"/>
I know it is possible to add a child node to a specific position with insertChildAfter() or insertChildBefore() but I don't know if it's possible for an attribute.

there's no native method for this, maybe you should create some functions for this. just like
private function setAttribute(node:XML, name:String, value:String, index:int = -1):void
    var attrs:XMLList = node.attributes().copy(),
        l:int = attrs.length();
    if(index == -1 || index > l - 1)
        node.@[name] = value;
    else
        delete node.@*;
        var idx:int = 0;
        for (var i:int = 0; i < l + 1; i++)
            if(i == index)
                node.@[name] = value;
            else
                var attr:XML = attrs[idx];
                node.@[attr.name()] = attr.toString();
                idx++;
and use it like this:
setAttribute(myNode, "otherAttribute", "abc", 0);

Similar Messages

  • How to add attributes in the xml tag

    hi,
    i have two tables employee,department
    employee table
    empno number,
    empname varchar2(100),
    deptno number,
    department table
    deptno number,
    deptname varchar2(100)
    i want xml file in the above mentioned two tables.The xml file is as follows,
    <?xml version="1.0" encoding="UTF-8" ?>
    <EmployeeInfo>
    <Data type="employee">
    <empno>1</empno>
    <empname>siva</empname>
    <deptno>10</deptno>
    </data>
    <Data type="department">
    <deptno>10</empno>
    <deptname>IT</empname>
    </data>
    </EmployeeInfo>
    can anybody please give plsql code for this requirement.i need to add attributes in the xml tag.Its urgent
    By
    Siva

    A general example (based on the OE sample data/tables)
    SQL>SELECT XMLElement("Emp",
      2                     XMLAttributes(employee_id AS "id"
      3                                  , '10' "dept"),
      4                     first_name||' '||last_name) as result
      5 FROM   employees e
      6 WHERE  department_id = 10;
    RESULT
    <Emp id="200" dept="10">Jennifer Whalen</Emp>

  • Create an attribute on an xml node

    Hello,
    I can't find how to make an attribute on an xml node using javascript.
    I have found assignNode() to create a node but nothing about attribute.
    Does anybody know about this ?
    Thanks by advance
    Samuel

    To use the assignNode, you will need to create the node first. You can use the xfa.form.createNode() method to create an object from the XFA object model hierarchy. This method returns an object reference which you then pass to assignNode() of the appropriate parent object

  • How to add a button in the view at a specific position

    Hi Gurus,
    We have a requirement :
    To add a button or image at a specific position in the view which is like an indicator showing different color
    based on another field .
    Example :
    Adding a button next to a drop down flield and changing the color of the button based on the name of the color choosen in the drop down .
    or Adding an image which can be changed based on the dropdown value or the value entered in the input field .
    Thanks ,
    Naval Bhatt.

    Hi,
    Create an Attribute ZINDICATOR , in the same context node in which the dropdown(picklist) attribute,exists.
    Let it be a CHAR 1 field.
    Implement GET_P and GET_ method.
    Pull this field beside the dropdown fields in view configuration.
    Now the code =>
    Implement the Get_P_ZINDICATOR for this attribute as explained by Robert
    Implement  Get_ZINDICATOR method as follows
      DATA:
         lr_current   TYPE REF TO if_bol_bo_property_access,
         lr_entity TYPE REF TO cl_crm_bol_entity,
         coll      TYPE REF TO if_bol_entity_col.
      lr_current ?= collection_wrapper->get_current( ).
    IF lr_current IS NOT BOUND.
       value = cl_thtmlb_util=>get_icon_url( 'check_empty.gif' ).
       RETURN.
    ELSE.
       dref = lr_current->get_property( 'ZINDICATOR' ) .
    ENDIF.
    IF dref IS NOT BOUND.
        value = cl_thtmlb_util=>get_icon_url( 'check_empty.gif' ).
        RETURN.
    ENDIF.
    TRY.
        value = if_bsp_model_util~convert_to_string( data_ref       = dref
                                                                                attribute_path = attribute_path
          IF value IS INITIAL.
            value = cl_thtmlb_util=>get_icon_url( 'check_empty.gif' ).
    *      ELSEIF  value EQ 'R'
    *        value = cl_thtmlb_util=>get_icon_url( 'check_overdue_status.gif' ). " gives RED LIGHT
          ELSEIF  value EQ 'Y' .
            value = cl_thtmlb_util=>get_icon_url( 'check_due_status.gif' ). " gives YELLOW light
          ELSEIF  value EQ 'G'.
            value = cl_thtmlb_util=>get_icon_url( 'check_nodue_status.gif' ). " gives GREEN light
          ENDIF.
    CATCH cx_bsp_conv_illegal_ref.
          CLEAR value.
          RETURN.
    CATCH cx_root.
          CLEAR value.
          RETURN.
    ENDTRY.
    Generally check_overdue_status.gif and other images are std. and are present in all skins.
    You need more colors then you have to add those images in the MIME repository in the images folder of the SAP SKIN folder.
    You must implement the eventhandler for Dropdown field. For this in the GET_P method of dropdown, use
    CASE iv_property
      WHEN  if_bsp_wd_model_setter_getter=>fp_server_event.
          rv_value = 'COLOUR_SELECTED'.
    ENDCASE.
    and then implement the event handler EH_ONCOLOUR_SELECTED.
    In this event handler, you must set the ZINDICATOR value as ' ' , 'R','G','Y' etc depending upon what is selected in dropdown.
    This ensures that a server roundtrip is triggered and so the GET method of indicator field is called as soon as dropdown value
    is selected.
    Hope this helps.
    Thanks & Regards
    Suchita

  • Add indent spaces to xml nodes with ms IXMLDOM

    Hi All,
      Currently I was update a xml file with IXMLDOM, after add nodes to xml file, we found the new added node was written in one line always.  this make it hard to find the differences with merge tools.
      and after we try to add text node to the xml to format it, it works unless we added nested nodes, it looks like:
    <RootNode>
    <ChildNodes>
    <Child>value</Child></ChildNodes></RootNode>
    Ugly, huh
    And, when we set node's type with IXMLDOMNode::put_dataType it makes the node like:
    <Name xmlns:dt="urn:schemas-microsoft-com:datatypes" dt:dt="string" Encoding="Standard" >Connections</Name>
    but, the original nodes was: 
    <Name dt:dt="string" Encoding="Standard" xmlns:dt="urn:schemas-microsoft-com:datatypes">Connections</Name>
    Also, it will not affect the its function, just cause extra efforts to merge the results.
    So my questions:
       1. is there any built-in functions that can be used to format the xml file to a indented version. 
       2. how to adjust the sequences of attributes of a node.
    Thanks, 
    Levi
    PS: currently, I was working on Windows CE 6.0, and these issues met on desktop OS too.
    One world, one dream

    >   1. is there any built-in functions that can be used to format the xml file to a indented version. 
    I used to use this code in a previous version of a project. I don't
    know if CE 6 will support it though.
    static bool FormatDOMDocument( MSXML2::IXMLDOMDocument *pDoc )
        // Create the writer
        CComPtr <IMXWriter> pMXWriter;
        if (FAILED (pMXWriter.CoCreateInstance(__uuidof (MXXMLWriter),
    NULL, CLSCTX_ALL)))
            return false;
        CComPtr <ISAXContentHandler> pISAXContentHandler;
        if (FAILED (pMXWriter.QueryInterface(&pISAXContentHandler)))
            return false;
        CComPtr <ISAXErrorHandler> pISAXErrorHandler;
        if (FAILED (pMXWriter.QueryInterface (&pISAXErrorHandler)))
            return false;
        CComPtr <ISAXDTDHandler> pISAXDTDHandler;
        if (FAILED (pMXWriter.QueryInterface (&pISAXDTDHandler)))
            return false;
        if (FAILED (pMXWriter->put_omitXMLDeclaration (VARIANT_FALSE))
    ||
            FAILED (pMXWriter->put_standalone (VARIANT_TRUE)) ||
            FAILED (pMXWriter->put_indent (VARIANT_TRUE)) ||
            FAILED (pMXWriter->put_encoding (L"UTF-8")))
            return false;
        // Create the SAX reader
        CComPtr <ISAXXMLReader> pSAXReader;
        if (FAILED(pSAXReader.CoCreateInstance(__uuidof
    (SAXXMLReader), NULL, CLSCTX_ALL)))
            return false;
        if (FAILED(pSAXReader->putContentHandler
    (pISAXContentHandler)) ||
            FAILED(pSAXReader->putDTDHandler (pISAXDTDHandler)) ||
            FAILED(pSAXReader->putErrorHandler
    (pISAXErrorHandler)) ||
            FAILED(pSAXReader->putProperty(
    reinterpret_cast<unsigned short*>(
    L"http://xml.org/sax/properties/lexical-handler" ), CComVariant
    (pMXWriter))) ||
            FAILED(pSAXReader->putProperty(
    reinterpret_cast<unsigned short*>(
    L"http://xml.org/sax/properties/declaration-handler" ), CComVariant
    (pMXWriter))))
            return false;
        // Perform the write
        bool success1 = SUCCEEDED( pMXWriter->put_output(
    CComVariant(pDoc ) ) );
        bool success2 = SUCCEEDED( pSAXReader->parse( CComVariant(
    pDoc ) ) );
        return success1 && success2;
    Dave

  • Select XML Node by a specific attribute value

    I am newbie for LifeCyle.
    This might be an easy question, but it really got me here.
    I am trying bind xml data into a Drop-Down List. The databinding is working fine, but I would like to have more specific node selected from the xml file by using a attribute value.
    for example Code in AS 3.0
    root.node.(@id=="1").subNode
    How could i do the same thing in LifeCycle Designer 8.0
    Thank you in advance!!!

    there's no native method for this, maybe you should create some functions for this. just like
    private function setAttribute(node:XML, name:String, value:String, index:int = -1):void
        var attrs:XMLList = node.attributes().copy(),
            l:int = attrs.length();
        if(index == -1 || index > l - 1)
            node.@[name] = value;
        else
            delete node.@*;
            var idx:int = 0;
            for (var i:int = 0; i < l + 1; i++)
                if(i == index)
                    node.@[name] = value;
                else
                    var attr:XML = attrs[idx];
                    node.@[attr.name()] = attr.toString();
                    idx++;
    and use it like this:
    setAttribute(myNode, "otherAttribute", "abc", 0);

  • How to get nodes and its attributes of an XML file usiong DOM parsing?

    how to get nodes and its attributes of an XML file usiong DOM parsing?
    i am new to XML parsing.......
    Thanking you........

    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;      ...
    //Setup the document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
         Document doc = docBuilder.parse (new File("MY_XML_FILE.xml"));
    //get elemets by name
         String elementValue = doc.getElementsByTagName("MY_ELEMENT").item(0).getTextContent();
    //This method can return multiple nodes, in this instance I get item(0) , first nodeRead the api for other methods of getting data.

  • Read a XML node value/attribute value from a CLOB

    Hello,
    I can write SQL/ - PL/SQL "straightforward" but now I have a problem what is to big for me.  I hop that someone can help.
    We create by code a xml structure and write these into the oracle database CLOB field. I'm sorry to say that a xml text structure is written into a clob in stead of a xmltype field. (it's a design failure?) It's a large xml structure. I believe I can't attach a file so I put at the end of this discussion a light example of the xml structure.
    It's a xml with quartervalue's, so there are 35040 detail rows (24h * 4 * 365days). I want to accumulate the the attribute Amount value 9. The amount value is in the Detail node a attribute but at the end you can see that for the DST are also 4 value's, but these are not attribute value's but node value's. (In this case it are four value's in some cases there is one DST amount value.
    Can somebody help me how to accumulate all the detail attribute value Amount with the node value Amount of the DST tag?
    XML structure:
    <?xml version="1.0"?>
    <Message xmlns:ns1="http://automaticdealcapture/">
        <BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
            <DocumentData>
                <ns1:Adcs>
                    <ns1:Package>
                        <ns1:Deal>
                            <ns1:ProductCode>PWCODE</ns1:ProductCode>
                            <ns1:Action>NEW</ns1:Action>
                            <ns1:Memo1>MemoField</ns1:Memo1>
                            <ns1:Details>
                                <ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
                                <ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
                                etc. 350040 detail rows.
                            </ns1:Details>
                            <ns1:DSTS>
                                <ns1:Year Val="2014">
                                    <ns1:DST Period="1">
                                        <ns1:Amount>0.0146</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="2">
                                        <ns1:Amount>0.0222</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="3">
                                        <ns1:Amount>0.0444</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="4">
                                        <ns1:Amount>0.0146</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                </ns1:Year>
                            </ns1:DSTS>
                        </ns1:Deal>
                    </ns1:Package>
                </ns1:Adcs>
            </DocumentData>
        </BusinessDocument>
    </Message>

    From what I know, extracting the "Amount" values in the Details section and the "Amount" values in the DSTS section would be two different SELECT statements.
    Both of these will use XMLTable() to extract the values.
    BTW - If you need more information on this, post up in the XML/XML DB forum section for more complex help.  (eg getting YEAR with the DSTS Amount values)
    as far as XML size goes, I've seen oracle handle a 100MB XML document without problems.
    (just understand, it will be 'slow')
    This one will give you the Amount values from the DSTS section:
    with xml_data as ( SELECT
    XMLType('<?xml version="1.0"?>
    <Message xmlns:ns1="http://automaticdealcapture/">
        <BusinessDocument messageDateTime="2013-10-25T13:59:31+02:00" ediReference="LO-461967" messageName="New" businessSector="Z" documentFunction="Original">
            <DocumentData>
                <ns1:Adcs>
                    <ns1:Package>
                        <ns1:Deal>
                            <ns1:ProductCode>PWCODE</ns1:ProductCode>
                            <ns1:Action>NEW</ns1:Action>
                            <ns1:Memo1>MemoField</ns1:Memo1>
                            <ns1:Details>
                                <ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="00:00:00" Timee="01:00:00" Amount="0.0153" Price="11.111"/>
                                <ns1:Detail Dates="2014-01-01" Datee="2014-01-01" Times="01:00:00" Timee="02:00:00" Amount="0.015" Price="22.222"/>
                            </ns1:Details>
                            <ns1:DSTS>
                                <ns1:Year Val="2014">
                                    <ns1:DST Period="1">
                                        <ns1:Amount>0.0146</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="2">
                                        <ns1:Amount>0.0222</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="3">
                                        <ns1:Amount>0.0444</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                    <ns1:DST Period="4">
                                        <ns1:Amount>0.0146</ns1:Amount>
                                        <ns1:Price>33.333</ns1:Price>
                                    </ns1:DST>
                                </ns1:Year>
                            </ns1:DSTS>
                        </ns1:Deal>
                    </ns1:Package>
                </ns1:Adcs>
            </DocumentData>
        </BusinessDocument>
    </Message>') as XMLDATA from dual
    select Y.amount
    from xml_data X,
      XMLTable(  XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
       '/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:DSTS/ns1:Year/ns1:DST'
        passing X.XMLData
      COLUMNS
        amount Number PATH '/ns1:DST/ns1:Amount'
      ) Y;
    Replace the XMLTable() with the one below to get the Amount from the Details section:
      XMLTable(  XMLNAMESPACES( 'http://automaticdealcapture/' as "ns1"),
       '/Message/BusinessDocument/DocumentData/ns1:Adcs/ns1:Package/ns1:Deal/ns1:Details/ns1:Detail'
        passing X.XMLData
      COLUMNS
        amount number PATH '/ns1:Detail/@Amount'
      ) Y;

  • I met problems about XML Node attributes in Flex 2.0

    Here is my example
    <Root Pro1="1">
    <TestNode />
    </Root>
    I get the XML from HTTPService:
    var xmlData:XML = new XML(hsTest.lastResult);
    I can get the value by the method "attribute()":
    xmlData.attribute("Pro1"); // correct
    But if i try the code:
    xmlData.attribute("Pro2"); // Not null,and even not "", but i
    really do not know what it is.It just shows blank in "Alert.show()"
    method.
    In the fact, i want to check whether the XML Node has a
    certain property.Finally i find the method "hasOwnProperty()", but
    it does not seem to work like its name:
    xmlData.hasOwnProperty("Pro1"); // return false
    xmlData.hasOwnProperty("Pro2"); // return fasle
    I wonder how i should code it.
    Thanks in advance.

    If you look at the return value of the attribute() method,
    it's an XMLList. You can think of it as an array of XML objects. In
    this case, it returned an empty XMLList. Just check whether
    length() is 0 is not.

  • Add attributes of dataTemplate, custom format, xml output

    I need to format dataTemplate tag, in xml-output.
    E.g.
    <myDataTemplate_tag_name SchemaVersion="1.0" xmlns="http://www.oracle.com/">
    Now, I have in xml
    <dataTemplate name="myDataTemplate_tag_name" defaultPackage="ccc_pack" version="1.0" description='SchemaVersion=\"1.0\" xmlns=\"http://www.oracle.com/\"'>
    but not work.
    Any suggestion? How can I add attributes?
    Thanks.
    kale.
    Edited by: kaleonardo on Oct 22, 2009 3:02 AM
    Edited by: kaleonardo on Oct 22, 2009 7:12 AM

    I discovered, I can make a xsl-xml template for manipulating tag name and attribute.
    Now, my problem is to keep all informations which are in main tag.
    Eg.
    my xml:
    <?xml version="1.0" encoding="UTF-8" ?>
    <InsNewArrival>
    <InsCodeVersions>
    <CountryVer>2007</CountryVer>
    <EuCountryVer>2007</EuCountryVer>
    <CnVer>2008</CnVer>
    <ModeOfTransportVer>2005</ModeOfTransportVer>
    <DeliveryTermsVer>2005</DeliveryTermsVer>
    <NatureOfTransactionAVer>2005</NatureOfTransactionAVer>
    <NatureOfTransactionBVer>2005</NatureOfTransactionBVer>
    <CountyVer>1</CountyVer>
    <LocalityVer>06/2006</LocalityVer>
    <UnitVer>1</UnitVer>
    </InsCodeVersions>
    </InsNewArrival>
    after xsl
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="InsNewArrival/*">
    <InsNewArrival>
    <xsl:attribute name="SchemaVersion">1.0</xsl:attribute>
    </InsNewArrival>
    </xsl:template>
    </xsl:stylesheet>
    I have
    <?xml version="1.0" encoding="UTF-8" ?>
    <InsNewArrival SchemaVersion="1.0" />
    not
    <?xml version="1.0" encoding="UTF-8" ?>
    <InsNewArrival SchemaVersion="1.0" xmlns="http://www.intrastat.ro/xml/InsSchema">
    <InsCodeVersions>
    <CountryVer>2007</CountryVer>
    <EuCountryVer>2007</EuCountryVer>
    <CnVer>2008</CnVer>
    <ModeOfTransportVer>2005</ModeOfTransportVer>
    <DeliveryTermsVer>2005</DeliveryTermsVer>
    <NatureOfTransactionAVer>2005</NatureOfTransactionAVer>
    <NatureOfTransactionBVer>2005</NatureOfTransactionBVer>
    <CountyVer>1</CountyVer>
    <LocalityVer>06/2006</LocalityVer>
    <UnitVer>1</UnitVer>
    </InsCodeVersions>
    </InsNewArrival>
    Thanks.
    kale

  • Imported XSLT cannot create attributes for generated XML element

    I have two xslts. One imports the other.
    The imported xslt creates XML elements with attributes and this XML is stored in a variable in the main stylesheet
    If I perform the transformation with JRE prior to 1.6.0.18 then all works fine
    If I use 1.6.0.18 or 1.6.0.19 then the attributes aren't added.
    If I add attributes in the main xslt it works fine or if I output the element directly instead of first storing it in a variable then it also works fine.
    Problem seems to be when you try to add attributes from an imported stylesheet and store the generated element in a variable.
    Below two stylesheets to illustrate :
    First MainStylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- Copyright 1993-2005 Seagull Software Systems, Inc. -->
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    extension-element-prefixes="exsl"
    exclude-result-prefixes="xs">
    <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes" />
    <xsl:import href="innerstylesheet.xsl"/>
    <xsl:template match="/TestData">
    <xsl:variable name="generatedElementXml">
    <xsl:call-template name="generateElement">
    <xsl:with-param name="s">testValue</xsl:with-param>
    </xsl:call-template>
    </xsl:variable>
    <xsl:for-each select="exsl:node-set($generatedElementXml)">
    *** GeneratedElementXML {<xsl:text>
    </xsl:text><xsl:copy-of select="*"></xsl:copy-of>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>Next innerstylesheet.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:exsl="http://exslt.org/common"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    extension-element-prefixes="exsl" >
            <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
            <xsl:template name="generateElement">
                       <xsl:param name="s"/>
                    <TestElement testAttribute="$s" />
            </xsl:template>
    </xsl:stylesheet>The result output by jres before 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" testAttribute="testValue"/>
                   }          The result output by jres since 1.6.0.18 is :
    <?xml version="1.0" encoding="UTF-8"?>
                   *** GeneratedElementXML {
              <TestElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                   }          Note : the 'testAttribute' attribute is missing

    Have found the difference in the code
    In both JRE1.6.0_17 & JRE1.6.0_18, the class 'com.sun.org.apache.xalan.internal.xsltc.dom.AdaptiveResultTreeImpl' has the following method
    public void addUniqueAttribute(String qName, String value, int flags)
            throws SAXException
            addAttribute(qName, value);
        }In JRE1.6.0_17 the next method is
    public void addAttribute(String name, String value)
         if (_openElementName != null) {
             _attributes.add(name, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, name);
        }In JRE1.6.0_18 the next method is
    public void addAttribute(String uri, String localName, String qname,
                String type, String value)
         if (_openElementName != null) {
             _attributes.addAttribute(uri, localName, qname, type, value);
         else {
             BasisLibrary.runTimeError(BasisLibrary.STRAY_ATTRIBUTE_ERR, qname);
        }Note - the addAttribute method has additional parameters in JRE1.6.0_18 but the call from addUniqueAttribute wasn't updated.
    So in JRE1.6.0_18 addUniqueAttribute actually invokes the following method in the base package com.sun.org.apache.xml.internal.serializer.EmptySerializer
    public void addAttribute(String name, String value)
            aMethodIsCalled();
    void aMethodIsCalled()
            // throw new RuntimeException(err);
            return;
        }and as you can see this does nothing. Hence the fact that the attribute isn't added.

  • Xml in JTree: how to not collpase JTree node, when renaming XML Node.

    Hi.
    I'm writing some kind of XML editor. I want to view my XML document in JTree and make user able to edit contents of XML. I made my own TreeModel for JTree, which straight accesses XML DOM, produced by Xerces. Using DOM Events, I made good-looking JTree updates without collapsing JTree on inserting or removing XML nodes.
    But there is a problem. I need to produce to user some method of renaming nodes. As I know, there is no way to rename node in w3c DOM. So I create new one with new name and copy all children and attributes to it. But in this way I got a new object of XML Node instead of renamed one. And I need to initiate rebuilding (treeStructureChanged event) of JTree structure. Renamed node collapses. If I use treeNodesChanged event (no rebuilding, just changes string view of JTree node), then when I try to operate with renamed node again, exception will be throwed.
    Is there some way to rename nodes in my program without collpasing JTree?
    I'am new to Java. Maybe there is a method in Xerces DOM implementation to rename nodes without recreating?
    Thanks in advance.

    I assume that "rename" means to change the element name? Anyway your question seems to be "When I add a node to a JTree, how do I make sure it is expanded?" This is completely concerned with Swing, so it might have been better to post it in the Swing forum, but if it were me I would do this:
    1. Copy the XML document into a JTree.
    2. Allow the user to edit the document. Don't attempt to keep an XML document or DOM synchronized with the contents of the JTree.
    3. On request of the user, copy the JTree back to a new XML document.
    This way you can "rename" things to the user's heart's content without having the problem you described.

  • Access attribute of a context node in another context node of the same view

    Hi all,
    I want to acess value of an attribute PERNR of context node CUSTOMERS in another context node AUTHENTICATION of the same view. A sample syntax would be helpful .
    Thanks,

    You didn't specify your version of Oracle so here are two options. If 10.2 or greater, use XMLTable, else use the ExtractValue option.
    -- The WITH simply simulates your existing table that I do not have.
    WITH fake_tab AS
    (SELECT XMLTYPE('<?xml version="1.0" encoding="ISO-8859-1"?>
    <Settings>
      <Setting Name="A1" Value="N"/>
      <Setting Name="A2" Value="N"/>
      <Setting Name="A3" Value="SOMEVALUE"/>
      <Setting Name="A4" Value="N"/>
      <Setting Name="A5" Value="Y"/>
      <Setting Name="A6" Value="N"/>
    </Settings>
    ') tab_col
      FROM dual)
    -- For 10.2 and higher use this SELECT
    SELECT a5
      FROM fake_tab,
           XMLTABLE('/Settings'
                    PASSING fake_tab.tab_col
                    COLUMNS
                    a5   VARCHAR2(10)  PATH 'Setting[@Name="A5"]/@Value');
    -- For 10.1 and before
    SELECT ExtractValue(tab_col, '/Settings/Setting[@Name="A5"]/@Value')
      FROM fake_tab;

  • Using XSLT to extract value of a XML node with namespace

    I have a XML source code here.
    <?xml version="1.0" encoding="utf-8" ?>
    <rss version="2.0" xmlns:job="http://www.pageuppeople.com">
      <channel>
        <title>SMH Jobs</title>
        <link>internalrecruitment.smhgroup.com.au/jobsrss.ashx?stp=di</link>
        <description>A listing of jobs available here</description>
        <item>
          <title>eCommerce Optimisation Advisor</title>
          <description>A new and exciting opportunity exists for an experienced eCommerce Advisor to join</description>
          <job:location PUReferenceID="3711">Sydney - Inner Suburbs & CBD</job:location>
        </item>
      </channel>
    </rss>
    I want to use XSLT to extract value of a XML node with namespace <job:location>, and the returned value should be string 'Sydney - Inner Suburbs & CBD'. I tried a few XSL code below, but failed with error or nothing was returned.
    <xsl:value-of select="job:location" disable-output-escaping="yes"/>
    <xsl:value-of select="job/location" disable-output-escaping="yes"/>
    <xsl:value-of select="job\location" disable-output-escaping="yes"/>
    <xsl:value-of select="location" disable-output-escaping="yes"/>
    This might be an easy question for you, but I would appreciate if anyone can help.

    Hi Suncorp IT Learner,
    We need to tell the XSLT that some elements are in another namespace. Copy the xmls declarations for the prefixes you need to use. Then use the xsl format as:
    <xsl: value-of select=”job:location/@PUReferenceID”/>
    In following issue, Chriztian has a good explanation:
    http://our.umbraco.org/forum/developers/xslt/33353-XSLT-reading-XML-attribute-value
    Thanks,
    Qiao Wei
    TechNet Community Support

  • How to define a  multivalued attribute in spml2.xml(spml2PersonForm)?

    I need to define a multivalued attribute in spml2.xml for modifying security answers and adding resources during add request. I tried by giving multivalued="true" during the attribute definition.
    <spmldsml:attributeDefinition name="questions" description="Secret questions" multivalued ="true"/>
    but still the lookup response shows the value as a single attribute
    <dsml:attr xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='questions'>
    <dsml:value>[What is your mother's maiden name?, asrfasdhfgjk, adsggfjhgkjhl]</dsml:value>
    </dsml:attr>
    Kindly suggest if i missed out anything during the configuration.

    Hi!
    I was unable to post any message. It was displaying that "Message blocked".
    Please help me in this issue.
    Regards
    Mourya

Maybe you are looking for

  • Adobe Photoshop Elements12 onto a Mac

    I just purchased an Apple MacBook Pro with Retina Display. I also purchased a copy of Adobe Premiere Elements 12 and a USB SuperDrive to download the software onto the Mac. The drive just spits out the Disk after a couple of seconds and I can not dow

  • How do I change the name of my Mac

    How do I change the name of my Mac

  • Launching Mail becomes a runaway process and creates a massive memory leak in the kernel task

    I have 16gig of ram, my kernel task is currently using 12gig, Mail is no longer responding while using all remaining ram Mail has been jammed at 100% of one i7 core for about 2 hours now, disk activity is almost nonexistant. it was running poorly yes

  • Changing the start disk on Mac Pro?

    On my Mac Pro the start disk is the smallest of two disks and it is packed. This is become a huge problem. I need space because of film production. As it is now I cannot install new programs, which I need. So how do I solve this problem? Fast. E

  • System copy on target system problem

    Dear All Please help me I system copy on targer system problem (Java Migration Tool Kit) and debug with SAP NOTE 1119190 but I can't find jmt.jar. This is log runJmt.log java.lang.reflect.InvocationTargetException      at sun.reflect.NativeMethodAcce