Adding XML Attriubutes to Nodes

Hello,
I'm working on a project that requires parsing of messages between server and client programs and we're using XML as the language.
The server is programmed in C# and the client in Java ..
I need something like this:
<ROOM>
<TYPE message="CREATE">
// A create type message goes in here
</TYPE>
</ROOM>
The following is the method that actually creates the message (located in the client) ...
public void CreateRoomOperationMessage (String toLocation, String roomName, String messageOperation) {
        // The create room operation message is a method which creates the create/kill messages
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            DOMImplementation impl = builder.getDOMImplementation();
            Document doc = impl.createDocument(null, toLocation, null);
            Node rootElement = doc.getDocumentElement();
            Node roomNode = doc.createElement(ROOM);
            rootElement.appendChild(roomNode);
            Node typeNode = doc.createElement(TYPE);
            roomNode.appendChild(typeNode);
            //Element typeElement = doc.getElementsByTagName(TYPE);
            //typeElement.setAttribute("MESSAGE", messageOperation);
            // PROBLEM ... NEED TO FIGURE OUT HOW TO INSERT AN ELEMENT INTO THE TREE?
            Text typeText = doc.createTextNode(messageOperation);
            typeNode.appendChild(typeText);
            Node roomNameNode = doc.createElement(ROOMNAME);
            roomNode.appendChild(roomNameNode);
            Text roomNameText = doc.createTextNode(roomName);
            roomNameNode.appendChild(roomNameText);
            TransformerFactory xformFactory = TransformerFactory.newInstance();
            Transformer idTransform = xformFactory.newTransformer();
            Source input = new DOMSource(doc);
            Writer txtWriter = new StringWriter();
            Result output = new StreamResult(txtWriter);
            idTransform.transform(input, output);
            setXmlMessage(txtWriter.toString());
        } catch (FactoryConfigurationError e) {
            System.err.println("ROOMMESSAGEFACTORY: Could not locate a JAXP factory class");
        } catch (ParserConfigurationException e) {
            System.err.println("ROOMMESSAGEFACTORY: Could not locate a JAXP DocumentBuilder class");
        } catch (DOMException e) {
            System.err.println("ROOMMESSAGEFACTORY: DOM Exception");
            System.err.println(e);
        } catch (TransformerConfigurationException e) {
            System.err.println("ROOMMESSAGEFACTORY: Input to Output transformation error!");
            System.err.println(e);
        } catch (TransformerException e) {
            System.err.println("ROOMMESSAGEFACTORY: Transformer Exception");
            System.err.println(e);
    }I just don't see any way of taking a node and setting/adding an attribute ...
eg .. Node typeNode = doc.createElement(TYPE);
roomNode.appendChild(typeNode);
typeNode.setAttribute("message", messageOperation); // This is the pseudocode

The return value of createElement() is an Element, and Element has a setAttribute method. Just don't implicitly upcast to Node and your pseudocode is correct.Element  typeNode = doc.createElement(TYPE);
roomNode.appendChild(typeNode);
typeNode.setAttribute("message", messageOperation);Pete

Similar Messages

  • Adding namespace qualified element nodes

    Is there a way to add namespace qualified element nodes to
    a document stored in a BDBXML container using the XmlModify class
    (BDBXML version 2.3.10, Linux)? Or, for that matter, any other
    handles?
    Particularly, is it possible to achieve this using the PHP
    extension?
    Let me give an example.
    When doing queries, you can set a namespace in the XmlQueryContext
    or in the XQuery expression itself:
    # prefix cannot be '' as of BDBXML 2.3.10
    $qc->setnamespace('a', 'http://as-guides.com/wev1');
    declare namespace a = "http://as-guides.com/wev1"; ...
    declare default element namespace "http://as-guides.com/wev1"; ...
    You can then refer to your namespace qualified elements as "a:Bla"
    etc. Or just as "Bla" if you make your namespace the default
    namespace.
    So far, so good.
    Now what if I want to add a namespace qualified element to
    my document? However I go about setting the namespace I always end
    up with either an apparently namespace qualified element which the
    namespace is not registered for or an element in the empty
    namespace.
    What I want is my element to adhere to the namespace
    "http://as-guides.com/wev1", which is set as the default
    element namespace in my document.
    Here is an example document.
    <Broadcast xmlns="http://as-guides.com/wev1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://as-guides.com/wev1 ds.xsd">
    <Start epoch="1186100400">2007-08-03T00:20:00Z</Start>
    <End epoch="1186100700">2007-08-03T00:25:00Z</End>
    <Content>
    <Title>Tagesschau</Title>
    <Genre>Nachrichten</Genre>
    </Content>
    </Broadcast>
    And here is my PHP code.
    $docname = '2007-08-02-1186100400-25758173-ard.xml_41368';
    $mgr = new xmlmanager;
    $cont = $mgr->opencontainer($argv[1]);
    $cont->addalias('tv');
    $qc = $mgr->createquerycontext();
    $qc->setnamespace('a', 'http://as-guides.com/wev1');
    $qexp = $mgr->prepare('/a:Broadcast', $qc);
    $mod = $mgr->createmodify();
    $mod->addappendstep($qexp, XmlModify_Element, 'a:now', time());
    $doc = $cont->getdocument($docname);
    $docval = new xmlvalue($doc);
    echo $docval->asString(), "\n";
    $uc = $mgr->createupdatecontext();
    $mod->execute($docval, $qc, $uc);
    Here is what gets added as last child node under "Broadcast":
    <a:now xmlns="">1189605065</a:now>
    So the namespace prefix I specified is added verbatim, without
    regard to the namespace settings in $qc (XmlQueryContext) - which
    do work fine for the query. No namespace declaration for "a"
    is added to the document. The resulting XML is invalid, as
    xmllint correctly points out.
    namespace error : Namespace prefix a on now is not defined
    So settings in XmlQueryContext do not seem to have any bearing on
    my update. XmlUpdateContext, on the other hand, does not have any
    methods defined for setting the namespace.
    Not setting the namespace in $qc (XmlQueryContext) and specifying
    it in the XQuery itself didn't work either. I left out the call to
    "setnamespace()" and changed the query to:
    declare default element namespace "http://as-guides.com/wev1";
    /Broadcast
    And I changed "a:now" to just "now". Here is what got added:
    <now xmlns="">1189607498</now>
    I didn't expect this second version to work, but I did expect the first
    one to work.
    What is the meaning of supplying XmlQueryContext to the execute()
    method?
    Is there a way to add namespace qualified elements to a document?
    If so, how can it be done?

    Thanks for your answer, George. I haven't quite understood how to make it do the trick, though.
    To change one document I did:
    dbxml> open tv.dbxml
    dbxml> setnamespace a http://as-guides.com/wev1
    Binding a -> http://as-guides.com/wev1
    dbxml> getdoc 2007-08-02-1186104300-25758380-sat1.xml_40564
    1 documents found
    dbxml> print
    <?xml version="1.0" encoding="UTF-8"?>
    <Broadcast xmlns="http://as-guides.com/wev1"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://as-guides.com/wev1 ds.xsd">
    <Start epoch="1186104300">2007-08-03T01:25:00Z</Start>
    <End epoch="1186105800">2007-08-03T01:50:00Z</End>
    <VPS>03:25</VPS>
    <Content>
    <Title>Moin</Title>
    </Content>
    </Broadcast>
    dbxml> append doc(2007-08-02-1186104300-25758380-sat1.xml_40564)/a:Broadcast element "" "<a:now xmlns:a='http://as-guides.com/wev1'>NOW</a:now>"
    Appending into nodes: doc(2007-08-02-1186104300-25758380-sat1.xml_40564)/a:Broadcast an object of type: element with name: and content: <a:now xmlns:a='http://as-guides.com/wev1'>NOW</a:now>
    0 modifications made.
    No change made to my document. I used the doc() function instead of collection() as in the example you gave. Using collection() as in your example (verbatim) I get an error message:
    stdin:17: append failed, Error: XmlModify::execute: Cannot perform a modification on an XmlValue that isn't either Node or Document type
    This is in the FAQ, but I don't quite get it.
    http://www.oracle.com/technology/products/berkeley-db/faq/xml_faq.html#49
    Anyway, I can still perform modifications outside of the container and then replace the document. Or wait till 2.4.
    Thanks for your answer and the good work. Regards,
    Michael

  • How to show an XML doc's node?/element in a dynamic textbox?

    Hello!
    I would like to show an XML doc's node?/element in a textbox. I am importing the XML data from a PHP page. My code looks like this:
    var xmlRequest:URLRequest = new URLRequest("adatatvitel.php");
    var xmlLoader:URLLoader = new URLLoader(xmlRequest);
    xmlLoader.addEventListener(Event.COMPLETE, init);
    function init(e:Event):void{ 
      var xmlDoc:XMLDocument = new XMLDocument();
      xmlDoc.ignoreWhite = true;
      var datasXML:XML = XML(xmlLoader.data);
      xmlDoc.parseXML(datasXML.toXMLString());
    This program would be a quiz. First I would like to write out the first data: Question with the appropriate Answers. If the player's answer is correct, the program would show the second set.  Thanks in advance!
    Here is my PHP code:
    <?php
    require("db.php");
    $sql = "SELECT * FROM kerdesvalasz";
    $result = mysql_query($sql) or die(mysql_error());
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    echo "<datas>";
    while($row = mysql_fetch_array($result))
      echo '<data>';
      echo '<question>'.$row['kerdes'].'</question>';
      echo '<answer1>'.$row['valasz1'].'</answer1>';
      echo '<answer2>'.$row['valasz2'].'</answer2>';
      echo '<answer3>'.$row['valasz3'].'</answer3>';
      echo '<answer4>'.$row['valasz4'].'</answer4>';
      echo '<correct>'.$row['helyes'].'</correct>';
      echo '</data>';
    echo "</datas>";
    ?>

    Hi Taly,
    Florian is right, you need to knwo / set a maximum columns ( i assumed he actually mean column) so that content being displayed will be visible on form.
    I would suggest you to reaccess to your solution again if this design and think what if you have 999 columns, how do you want to display the content in form .
    I would suggest to transpose your content to display as row in form, and let the content to flow.
    This should solve your issue.
    Hope this helps.
    regards,
    Xiang Li

  • Oracle SQL - Extracting clob value from XML with repeating nodes

    Hi All,
    I am attempting to run SQL on a table (called test_xml with a column xml_data [data type xmltype]). The column contains xml with repeating nodes (description). The following statement runs successfully when the node contains data of a non clob size:
    SELECT
    extractvalue (Value (wl), '*/description')
    FROM test_xml
    , TABLE (xmlsequence (extract (xml_data, '*/record'))) wl
    but fails when description node contains a lot of data:
    ORA-01706: user function result value was too large
    I amended my query:
    SELECT
    extractvalue(Value (wl), '*/description').getClobVal()
    FROM test_xml
    , TABLE (xmlsequence (extract (xml_data, '*/record'))) wl
    but this fails with:
    ORA-22806: not an object or REF
    Thanks in Advance

    Hi Greg,
    11.2.0.2.0 (Although I will need to do this on my work instance also which is 10.2.0.4)That's gonna be a problem...
    Direct CLOB projection is supported starting with 11.2.0.2, using XMLTable or XMLCast/XQuery functions (extractvalue, extract, xmlsequence are deprecated now) :
    SELECT x.*
    FROM test_xml t
       , XMLTable(
           '/*/record'
           passing t.xml_data
           columns
             description  clob path 'description'
         ) x
    ;On prior versions, implicit conversions will occur to VARCHAR2 datatype, hence the limitation observed.
    AFAIK you have two options on 10.2.0.4 :
    1) Using Object-Relational storage, with the xdb:SQLType="CLOB" annotation.
    2) Using the following trick :
    SELECT dbms_xmlgen.convert(x.description.getClobVal(), 1) as description
    FROM test_xml t
       , XMLTable(
           '/*/record'
           passing t.xml_data
           columns
             description  xmltype path 'description/text()'
         ) x
    ;

  • Adding multiple same-name nodes from one xml into another

    Hi,
    Following on from my question the other day (Adding multiple different nodes from one xmltype into another), I now have a slightly more complex requirement that I cannot work out where to start, assuming that it's something that can reuse some/all of yesterday's work (thanks again, odie_63!). ETA: I'm on 11.2.0.3
    So, here's the (slightly amended) xml along with yesterday's solution:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
    from sample_data sd;
    That gives me:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
      </xmlnode>
    </root>
    However, I now need to add in a set of new nodes based on information from the <multinode> nodes, something like:
    <root>
      <extrainfo>
        <b>valb</b>
        <d>
          <d1>vald1</d1>
          <d2>vald2</d2>
        </d>
        <f>valf</f>
        <h>
          <h1>valh1</h1>
          <h2>valh2</h2>
        </h>
        <newnode>
          <name>fred</name>
          <type>book</type>
        </newnode>
        <newnode>
          <name>bob</name>
          <type>car</type>
        </newnode>
      </extrainfo>
      <xmlnode>
        <subnode1>val1</subnode1>
        <subnode2>val2</subnode2>
        <type>book</type>
      </xmlnode>
      <xmlnode>
        <subnode1>val3</subnode1>
        <subnode2>val4</subnode2>
        <type>car</type>
      </xmlnode>
    </root>
    If it's easier, I *think* we would be ok with something like:
    <newnode>
      <type name="fred">book</type>
      <type name="bob">car</type>
    </newnode>
    The closest I've come is:
    with sample_data as (select xmltype('<root>
                                           <xmlnode>
                                             <subnode1>val1</subnode1>
                                             <subnode2>val2</subnode2>
                                           </xmlnode>
                                           <xmlnode>
                                             <subnode1>val3</subnode1>
                                             <subnode2>val4</subnode2>
                                           </xmlnode>
                                         </root>') xml_to_update,
                                xmltype('<a>
                                           <b>valb</b>
                                           <c>valc</c>
                                           <d>
                                             <d1>vald1</d1>
                                             <d2>vald2</d2>
                                           </d>
                                           <e>vale</e>
                                           <f>valf</f>
                                           <g>
                                             <g1>valg1</g1>
                                             <g2>valg2</g2>
                                           </g>
                                           <h>
                                             <h1>valh1</h1>
                                             <h2>valh2</h2>
                                           </h>
                                           <multinode>
                                             <name>fred</name>
                                             <type>book</type>
                                             <head>1</head>
                                           </multinode>
                                           <multinode>
                                             <name>bob</name>
                                             <type>car</type>
                                             <head>0</head>
                                           </multinode>                                        
                                         </a>') xml_to_extract_from
                          from   dual)
    select xmlserialize(document
               xmlquery(
                 'copy $d := $old
                  modify (
                    insert node element extrainfo {
                      $new/a/b
                    , $new/a/d
                    , $new/a/f
                    , $new/a/h
                    , element newnode {
                                       $new/a/multinode/name
                                       ,$new/a/multinode/type
                    } as first into $d/root
                  return $d'
                 passing sd.xml_to_update as "old"
                       , sd.xml_to_extract_from as "new"
                 returning content
             indent
             ) fred
    from sample_data sd;
    Which produces:
    <newnode>
      <name>fred</name>
      <name>bob</name>
      <type>book</type>
      <type>car</type>
    </newnode>
    - obviously not right!
    Can anyone provide any hints? I've tried searching for similar examples, but I mustn't be putting in the right search terms or something!

    odie_63 wrote:
    or, similarly, to get the alternate output :
    copy $d := $old
    modify (
      insert node element extrainfo {
        $new/a/b
      , $new/a/d
      , $new/a/f
      , $new/a/h
      , element newnode {
          for $i in $new/a/multinode
          return element type {
            attribute name {data($i/name)}
          , data($i/type)
      } as first into $d/root
    return $d
    So we're going with the second method, but I've discovered that the "$i/name" node is not always present. When that happens, I would like to use a default value (for example, "george"). I promise I've searched and searched, but I'm completely failing to turn up anything that sounds remotely like what I'm after (seriously, I can't believe my google-fu sucks this badly!).
    Is there a simple way of doing it? The only thing that I've found that looks vaguely relevant is "declare default namespace...." but I'm not sure that that's the correct thing to use, or if it is, how I'm supposed to reference it when populating the attribute value.

  • XML export root node attriubute?

    Hi
    I need to use XML export extension to generate XML to something like this:
    <photos path="images/">
    <photo id="1" name="Photo 1" blabla ="" url="1.jpg">This is the optional description for photo 1</photo>
    <photo id="2" name="Photo 2" blabla ="" url="2.jpg">This is the optional description for photo 2</photo>
    <photo id="3" name="Photo 3" blabla ="" url="3.jpg">This is the optional description for photo 3</photo>
    <photo id="4" name="Photo 4" blabla ="" url="4.jpg">This is the optional description for photo 4</photo>
    <photo id="5" name="Photo 5" blabla ="" url="5.jpg">This is the optional description for photo 5</photo>
    </photos>
    The problem is the root nodes path="images/"
    Is there a way to edit the XMLExport.class.php to do that?
    I can in DW edit the $xmlExportObj->setRootNode('photos'); to $xmlExportObj->setRootNode('photos path="images/"');
    But that gives an error because the end node looks like </photos path="images/">
    Hopefully there is an easy fix for this
    Regards
    olle

    Thank you both.
    Acctually I found out a quick way. I edit the XMLExport.class.php
    In the bottom just before the headers i just put in:
    $document .= '</Photos>';
    Instead of:
    $document .= '</' . $this->rootNodeName . '>';
    Off course this is not so dynamic. And can only be used for the page I want.
    Otherwise I think that the Spry export to XML is great.
    Regards
    olle

  • Is there better way to do this?  (Xml Pretty Print | node removing)

    Hi all, I have been working at home on a small project to help my Java Jedi training. :-)
    My app saves quotes from authors in an xml file.
    I have a class [XmlRepository extends Thread] that holds control of an xml file to handle requests for Nodes.
    When I remove a node I get a Line Space above the node that was removed, or better put my node gets replaced by a empty line.
    Pretty print or correct Node removing.
    part of my xml is like this (I have resumed it for readability):
        <entities forUser="ffffffff-ffff-ffff-ffff-ffffffffffff">
            <quotes/>
            <authors>
                <author id="f156c570-c676-4d69-9b15-ae7d859ff771" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Poe</lastNames>
                    <firstNames>Edgar Allan</firstNames>
                </author>
                <author id="35dc0c5a-3813-4a10-af49-8d4ea1c2cee0" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Wilde</lastNames>
                    <firstNames>Oscar</firstNames>
                </author>
                <author id="317f72ea-add6-4bd2-8c63-d8b373a830ab" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Christie</lastNames>
                    <firstNames>Agatha</firstNames>
                </author>
                <author id="28047c89-b647-4c40-b6c7-677feaf2dfda" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Shakespeare</lastNames>
                    <firstNames>William</firstNames>
                </author>
            </authors>
        </entities>If I remove A Node ( Edgar Allan Poe (1st in this case)) the resulting Xml when saved is like this (I have added the space indentation just as it is outputted by my code):
        <entities forUser="ffffffff-ffff-ffff-ffff-ffffffffffff">
            <quotes/>
                <author id="35dc0c5a-3813-4a10-af49-8d4ea1c2cee0" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Wilde</lastNames>
                    <firstNames>Oscar</firstNames>
                </author>
                <author id="317f72ea-add6-4bd2-8c63-d8b373a830ab" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Christie</lastNames>
                    <firstNames>Agatha</firstNames>
                </author>
                <author id="28047c89-b647-4c40-b6c7-677feaf2dfda" languageCode="en" regenerateAs="com.fdt.cognoscere.entities.sources.Author">
                    <lastNames>Shakespeare</lastNames>
                    <firstNames>William</firstNames>
                </author>
            </authors>
        </entities>this is how I initialize the XML DOM Handlers, and the method for removing a Node:
         * Initializes factory instances and member variables.
        private void initialize() {
            //obtain an instance of a documentFactory create a document documentBuilder
            this.documentFactory = DocumentBuilderFactory.newInstance();
            //Configure the documentFactory to be name-space aware and validate trough an xsd file
            this.documentFactory.setNamespaceAware(true);
            this.documentFactory.setValidating(true);
            this.documentFactory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
            try {
                //obtain an instance of an XPathFactory
                this.xpathFactory = XPathFactory.newInstance(XPathFactory.DEFAULT_OBJECT_MODEL_URI);
                //obtain an instance of the xpath evaluator object
                this.xpathEvaluator = this.xpathFactory.newXPath();
                //set namespace mapping configurations
                NamespaceContextMap namespaceMappings = new NamespaceContextMap();
                namespaceMappings.put("xml", "http://www.w3.org/XML/1998/namespace");
                namespaceMappings.put("xmlns", "http://www.w3.org/2000/xmlns/");
                namespaceMappings.put("xsd", "http://www.w3.org/2001/XMLSchema");
                namespaceMappings.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                namespaceMappings.put(this.schemaNamespaceMapping, this.schemaNamespace);
                //add mappings
                this.xpathEvaluator.setNamespaceContext(namespaceMappings);
            } catch (XPathFactoryConfigurationException ex) {
                Logger.getLogger(XmlRepository.class.getName()).log(Level.SEVERE, null, ex);
            try {
                //obtain a trasformer factory to save the file
                this.transformerFactory = TransformerFactory.newInstance();
                this.transformerFactory.setAttribute("indent-number", 4);
                //obtain the transforme
                this.transformer = this.transformerFactory.newTransformer();
                //setup transformer
                this.transformer.setOutputProperty(OutputKeys.METHOD, "xml");
                this.transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                this.transformer.setOutputProperty(OutputKeys.MEDIA_TYPE, "text");
                this.transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
            } catch (TransformerConfigurationException tcex) {
                Logger.getLogger(XmlRepository.class.getName()).log(Level.SEVERE, null, tcex);
         * Removes a node by evaluating the XPATH expression.
         * @param xpath A String instance with the XPATH expression representing the element to remove.
         * @throws com.fdt.cognoscere.storage.exceptions.UnableToRemoveException When an exception occurs that prevents the repository to execute the remove statement.
        public void removeNode(final String xpath) throws UnableToRemoveException {
            Node nodeToRemove = null;
            Node parentNode = null;
            //verify xpath
            if (xpath == null)
                throw new IllegalArgumentException("The xpath argument cannot be null.");
            //verify that the repository is loaded
            if (!this.loaded)
                throw new IllegalStateException("The XmlRepository faild to load properly and it is in an invalid state. It cannot perfom any operation.");
            try {
                //get the node to remove out of the xpath expression
                nodeToRemove = this.getNode(xpath);
                //throw an exception if no node was found to remove
                if (nodeToRemove == null)
                    throw new UnableToFindException("The node element trying to be remove does not exist.");
                //obtain the parent node to remove its child
                parentNode = nodeToRemove.getParentNode();
                //remove the node from the parent node
                nodeToRemove = parentNode.removeChild(nodeToRemove);
            } catch.......removed to save space{
            } finally {
                //normalize document
                this.document.normalize();
        }Please tell me if I could do this better,
    thanks,
    f(t)

    franciscodiaztrepat wrote:
    When I remove a node I get a Line Space above the node that was removed, or better put my node gets replaced by a empty line.Replaced? No, there's already a new-line character after the node that was removed. And there was one before that node too. You didn't remove either of those, so after the removal there are two consecutive new-line characters. As you can see.
    And no, trying to pretty-print the XML document won't remove any of those. It might add whitespace to make the document nicely indented, but it won't ever remove whitespace. If you want whitespace removed then you'll have to do it yourself.
    For example, after you remove a node, also remove the node following it if it's a whitespace text node. Or something like that.

  • How can I see more than 100 users when adding users to a node?

    When adding new users through the User Management interface, only the
    first 100 entries are listed. How do I increase the number of entries
    so I can see the next hundred (or more) users? Is this done via the server
    configuration parameter maxsearchresult?
    <P>
    The GUI Add User to Node option was meant for infrequent adds in smaller
    environments. In large deployments (more than 100 user adds at a time), you
    should be using the command line script "unidsattach". See the Administrators
    Guide for more details on the command.
    <p>
    The parameter, maxsearchresult, is meant to limit the number of users that can
    be returned on a search request by the calendar client. For example, if you have
    1000's of calendar users and someone tries to search for all of them, this
    parameter will make sure that the user is not left waiting a long time for
    results.

    In Settings > Notification Center, try turning "on" all the six buttons under "Today View".  Also turn "on" the top two buttons under "Access on Lock Screen".  Doing that should show you "Tomorrow" at the bottom of Noticiation Center.

  • XML: How to convert xml string into Node/Document

    I have a string in xml form.
    <name>
    <first/>
    <second/>
    </name>
    I want to convert this string into DOM Node or Document.
    How can I do this?
    Any help or pointer?
    TIA
    Sachin

    Try this :
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document doc = db.parse(new org.xml.sax.InputSource(new StringReader(strXml)));Hope this helps.

  • Adding a new DB Node in the existing SharePoint 2007 Farm.

    Hello,
    Recently we got a requirement to add a new DB server (SQL Server 2007) to the existing MOSS 2007 Production Farm. Can any one please help me out to list out the steps that need to be followed for adding the new DB server to the existing Production Farm.
    We are planning to use the new DB server only for holding Content DB's and no plan for any Config DB,SSP DB or Search DB.
    Thanks in advance for your help

    Hi,
    Also I am going to clone from Source app tier (RHEL4) to target app tier (RHEL5)?
    Are there any issue with the platform version changing?There should be no issue -- Just make sure you have all the OS pre-req. software and packages installed on the RHEL5 node.
    FAQ: Cloning Oracle Applications Release 11i [ID 216664.1] -- 13. Can I clone from one operating system version to another?
    Oracle Applications 11i Installation on OEL5 or RHEL5 [ID 730444.1]
    Oracle Applications Installation Update Notes, Release 11i (11.5.10.2) [ID 316806.1]
    Thanks,
    Hussein

  • Adding org.w3c.dom.Node

    Hi,
    can someone please tell me if it is posible do read a org.w3c.dom.Node from one XML file, and than add it to another? Or is there a way to copy one org.w3c.dom.Node to another XML?
    Thanx,
    Alan.

    Refer to
    http://javaalmanac.com/egs/org.w3c.dom/CloneSubtree2.html

  • Extracting xmltype from table into xml output:  redundant nodes

    Hi guys - see the below example.  (edit:   sorry, haven't used these forums for a while and can't seem to figure out how to format code.....)
    [code]SQL> select *
      2    from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    PL/SQL Release 11.2.0.4.0 - Production
    CORE    11.2.0.4.0      Production
    TNS for Linux: Version 11.2.0.4.0 - Production
    NLSRTL Version 11.2.0.4.0 - Production
    [/code]
    [/code]
    SQL> create table mytesttable (item_id number, x_data xmltype);
    Table created.
    SQL>
    SQL> insert into mytesttable
      2  with dat as (select 'blah' item from dual
      3               union all
      4               select 'more blah' from dual)
      5  ,t as (select xmlelement("x_data"
      6                              ,xmlattributes(1 as "dummyattr")
      7                              ,xmlagg(xmlelement("item"
      8                                                ,item))
      9                              ) x_data
    10              from dat
    11              )
    12  select 1,x_data
    13    from t    ;
    1 row created.
    SQL>
    SQL> select *
      2    from mytesttable;
       ITEM_ID
    X_DATA
             1
    <x_data dummyattr="1">
      <item>blah</item>
      <item>more blah</item>
    </x_data>
    1 row selected.
    SQL>
    SQL> select xmlelement("outerelement"
      2                   ,xmlelement("itemID", item_id)
      3                   ,xmlelement("x_data",x_data)
      4                   )
      5     from mytesttable;
    XMLELEMENT("OUTERELEMENT",XMLELEMENT("ITEMID",ITEM_ID),XMLELEMENT("X_DATA",X_DATA))
    <outerelement><itemID>1</itemID><x_data><x_data dummyattr="1">
    <item>blah</item>
    <item>more blah</item>
    </x_data>
    </x_data></outerelement>
    1 row selected.
    [/code]
    As the above, I have an xmltype in a table which has other non-xmltype columns.   I have a requirement to extract them out into a single xml document in a similar way to the last SQL there.
    the problem is if I do it as per the above, I artificially add a redundant node.  the first <x_data> node is not necessary, but how do I go and add the xmltype column to the result without having to qualify it with another element around it?
    i.e. how do I get the following:
    <outerelement><itemID>1</itemID><x_data dummyattr="1">
    <item>blah</item>
    <item>more blah</item>
    </x_data></outerelement>

    nevermind.. I was having a dumb moment:
    select xmlelement("outerelement"
                     ,xmlelement("itemID", item_id)
                     ,x_data
       from mytesttable;

  • Adding XML Declaration and Document Type Declaration.

    I'm using Oracle's XML Class Generator C++ version 1.0.2.0.0. I can create classes from a defined external DTD and create my XML document. But the document does not contain the XML Declaration <?xml version='1.0?> nor does it contain the Document Type Declaration <!DOCTYPE root-element-name SYSTEM "system-identifier">. What do I need to do to get these as part of my XML document? Does the class generator have methods to do this? Could someone show me an example?

    If you invoke the print method on the top-level ELEMENT, you get
    just the body of the document with no DTD or XMLDecl. if you invoke
    print on the top level NODE (the DOCUMENT node), then the output
    document will contain the XMLDecl and DTD.
    So please try to print from DOCUMENT node.

  • Adding xml fragment to SOAP body (SAAJ)

    Hi all,
    we are using SOAP (or better SAAJ) in a modular design as packaging/enveloping format for arbitrary payloads which are generated by different modules.
    How is it possible to add a xml fragment (as InputStream or DOM Node) to a SOAP Body ?
    Nick
    [email protected]

    Hi Vicky,
    I guess, we have a little misunderstanding here. The core SOAP specification defines the structure of the envelope, the "SOAP with attachments" specification extends that by defining how to add binary attachments. This is accomplished by using MIME. Every attachment is another MIMEPart, but the SOAP Envelope always has to be present as first MIMEPart. Now I don't want to add any attachments, I only want to construct a SOAP Envelope that contains arbitrary xml docs (fragments) in the body.
    Look at the example below, the tags with namespace "S" belong to the SOAP specification and are built by our SOAP layer, the tags with namespace "m" belong to some other namespace and are generated by a totally different component.
    My question was how I could add (within SAAJ) the xml fragment starting with "m:PurchaseOrder" to the envelope without having to add element by element.
    <S:Envelope>
         <S:Header>
              ...optional header tags
         </S:Header>
         <S:Body>
                    <!---from here it is a different namespace, SOAP doesn't know about PurchaseOrders>
              <m:PurchaseOrder>
                   <m:position>
                        <m:article>0815</m:article>
                        <m:description>mainboard</m:description>
                        <m:price>50</m:price>
                   </m:position>
                   <m:position>
                        <m:article>0816</m:article>
                        <m:description>cpu</m:description>
                        <m:price>100</m:price>
                   </m:position>
              </PurchaseOrder>
                    <!---from here, it is SOAP again>
         </S:Body>
    </S:Envelope>

  • Help needed adding xml into website

    I am looking for some help adding a few .xml files into my
    website using Dreamweaver
    First ..I would like to add the following RDS.xml file below.
    I would like it to go into a box that is 100 x 100 px
    <?xml version="1.0" encoding="utf-8" ?>
    - <Playing station="HAWK">
    - <item type="MUS">
    <DateTime>Thu 10:52AM</DateTime>
    <Cart />
    <Artist>THE ROLLING STONES</Artist>
    <SongTitle>JUMPIN' JACK FLASH</SongTitle>
    </item>
    </Playing>
    Second ..an event.xml file that will scroll info with box
    dimensions of 400 px w x 30 px h.
    Both xml files would be on my site in a user_files folder
    Any help would be greatly appreciated. Rob

    > To use Dreamweaver, you'll need to write some code to
    transform the XML
    > into
    > HTML. What code to write will depend on the server-side
    scripting language
    > you are using.
    It means that you can't just plop in XML in the middle of
    your HTML. Your
    pages are HTML, so the XML needs to be transformed in to HTML
    first. There
    are various ways to do this. Are you using PHP? ASP? Etc.
    Once we know that,
    we can narrow down a solution for you.
    -Darrel

Maybe you are looking for

  • Excel 2007 and Excel 2003 format

    Hi all, we have some problems with Excel file format on BPC 7.5NW SP06: 1- We save input schedules or reports woth Excel 2007 file format. Then when we try to open these report they are corrupted (we click on "Open" and nothing happens). We can downl

  • Photo Album buttons not working

    Hi, I created a photo album in Photoshop. This is how it views after it's created: http://oxford2.readyhosting.com/test/gallery/test.html When I put the file into my template the pause/play buttons aren't displaying. http://oxford2.readyhosting.com/t

  • Logic Pro on a MacBook Pro 17 - Will it Run Okay?

    I am getting ready to purchase a new Mac so I can record piano music and then add a bunch of midi instruments. I currently have an early MacBook Pro 17 maxed out at 2 GB RAM and I am having problems with it overheating when I run Finale Notation soft

  • Receiving Transaction Processor ERROR

    Hello Experts, Greetings! I have inserted data into rcv_headers_interface and rcv_transactions_interface to import the PO receipts into the RCV base tables. After executing 'Receiving Transaction Processor' , I am getting below given error , unable t

  • What we expect as customer from every brand

    Stable unit. proper software, aka no unstable software with bugs. Fast updates, and least as fast as competition not slower........ Lemme explain why the random shutdown issues are so anoying. Its software issue. Software issue means that 99.99% like