Yes i want to subscribe......
 
Thanks and Regards
Thej  Kishore.K 

Arise,Awake,Stop not till the goal is Reached-Swami Vivekanada.


----- Original Message ----
From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
To: dom4j-user@lists.sourceforge.net
Sent: Tuesday, August 28, 2007 3:11:41 AM
Subject: dom4j-user Digest, Vol 15, Issue 1

Send dom4j-user mailing list submissions to
    dom4j-user@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
    https://lists.sourceforge.net/lists/listinfo/dom4j-user
or, via email, send a message with subject or body 'help' to
    [EMAIL PROTECTED]

You can reach the person managing the list at
    [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of dom4j-user digest..."


Today's Topics:

   1. XPath problem (Ozakca, Muzaffer)
   2. Re: XPath problem (Ozakca, Muzaffer)
   3. Namespaces become blank when inserting or updating    elements
      (Jon Brisbin)
   4. Re: Namespaces become blank when inserting or updating
      elements (Evan Kirkconnell)
   5. Re: Namespaces become blank when inserting or updating
      elements (Jon Brisbin)
   6. Re: Namespaces become blank when inserting or updating
      elements (Evan Kirkconnell)


----------------------------------------------------------------------

Message: 1
Date: Thu, 9 Aug 2007 16:24:18 -0400
From: "Ozakca, Muzaffer" <[EMAIL PROTECTED]>
Subject: [dom4j-user] XPath problem
To: <dom4j-user@lists.sourceforge.net>
Message-ID:
    <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="utf-8"

Hi all,

 

I'm probably doing something very stupid. I have a very simple document and I

'm trying to apply an XPath to find the value of a node. Here's the XML:

 

<?xml version="1.0" encoding="UTF-8"?>

<sparql xmlns="http://www.w3.org/2001/sw/DataAccess/rf1/result";;>

  <head>

    <variable name="k0"/>

  </head>

  <results>

    <result>

      <k0 datatype="http://www.w3.org/2001/XMLSchema#double";>4.0</k0>

    </result>

  </results>

</sparql>

 

I can print this XML as it is read. And here?s the code, I?m using for XPath:

 

String sizeStr = sizeDoc.valueOf(?//k0?);

 

I get empty string as a result of this. Can anybody tell me what?s wrong? I 
added the whole lib directory in the dom4j distribution to the class path.

 

Thanks,

Muzaffer

-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 2
Date: Fri, 10 Aug 2007 09:49:08 -0400
From: "Ozakca, Muzaffer" <[EMAIL PROTECTED]>
Subject: Re: [dom4j-user] XPath problem
To: <dom4j-user@lists.sourceforge.net>
Message-ID:
    <[EMAIL PROTECTED]>
Content-Type: text/plain;    charset="utf-8"

I wish I was clever and did some research first. I found the answer in the list 
archives:

I should have done:

code ---
Map map = new HashMap();
map.put("result", "http://www.w3.org/2001/sw/DataAccess/rf1/result";;);
        
XPath xpath = DocumentHelper.createXPath("//result:k0");
xpath.setNamespaceContext(new SimpleNamespaceContext(map));
        
Node sizeNode = xpath.selectSingleNode(sizeDoc);
--- code

As suggested by Edwin. Thanks anyways,
m


------------------------------

Message: 3
Date: Mon, 27 Aug 2007 10:20:09 -0500
From: Jon Brisbin <[EMAIL PROTECTED]>
Subject: [dom4j-user] Namespaces become blank when inserting or
    updating    elements
To: dom4j-user@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Searched in the archives and didn't find what I was looking for (but not 
really sure what I'm looking for, so don't throw things at me if this 
has been asked before).

I have an XML template that I read into a DOM4J (using 1.6) document 
when I begin processing. The default namespace is set in the document 
and I set it again, just for good measure:

        SAXParser p = SAXParserFactory.newInstance().newSAXParser();

        DocumentFactory df = DocumentFactory.getInstance();
        df.setXPathNamespaceURIs( namespaces );

        SAXContentHandler ch = new SAXContentHandler();
        p.parse( ClassLoader.getSystemResourceAsStream( TEMPLATE_FILE ), ch );

        Document doc = ch.getDocument();
        doc.getRootElement().addNamespace( "", EFILE_NS );


When I process the raw data, I do XPath lookups on nodes in the template 
and set them like so:

            XPath xp = root.createXPath( xpath );
            xp.setNamespaceURIs( namespaces );
            Element e = (Element) xp.selectSingleNode( root );
            if ( e != null ) {
                e.setText( value );
                return e;
            } else {
                return root;
            }

But when the file is generated, some of the elements below the root 
element (but not all of them) have namespaces set to '' (blank). This 
causes the other party's XML processing to blow up with the error that 
the element with the blank namespace isn't in the E-file namespace, like 
it's supposed to be.

If the namespace is set in the template, then I would expect it work 
correctly when I've read that document in and set the namespaces 
accordingly. That's not happening and some elements in the DOM are being 
"taken out" of the default namespace.

Can someone shed some light on why this is happening?

-- 


Thanks!

Jon Brisbin
Portal Webmaster
NPC International, Inc.
http://www.npcinternational.com





------------------------------

Message: 4
Date: Mon, 27 Aug 2007 15:36:18 -0500
From: Evan Kirkconnell <[EMAIL PROTECTED]>
Subject: Re: [dom4j-user] Namespaces become blank when inserting or
    updating elements
To: dom4j-user@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Are you creating the problem elements with code or are they in your 
loaded document?

Jon Brisbin wrote:
> Searched in the archives and didn't find what I was looking for (but not 
> really sure what I'm looking for, so don't throw things at me if this 
> has been asked before).
>
> I have an XML template that I read into a DOM4J (using 1.6) document 
> when I begin processing. The default namespace is set in the document 
> and I set it again, just for good measure:
>
>         SAXParser p = SAXParserFactory.newInstance().newSAXParser();
>
>         DocumentFactory df = DocumentFactory.getInstance();
>         df.setXPathNamespaceURIs( namespaces );
>
>         SAXContentHandler ch = new SAXContentHandler();
>         p.parse( ClassLoader.getSystemResourceAsStream( TEMPLATE_FILE ), ch );
>
>         Document doc = ch.getDocument();
>         doc.getRootElement().addNamespace( "", EFILE_NS );
>
>
> When I process the raw data, I do XPath lookups on nodes in the template 
> and set them like so:
>
>             XPath xp = root.createXPath( xpath );
>             xp.setNamespaceURIs( namespaces );
>             Element e = (Element) xp.selectSingleNode( root );
>             if ( e != null ) {
>                 e.setText( value );
>                 return e;
>             } else {
>                 return root;
>             }
>
> But when the file is generated, some of the elements below the root 
> element (but not all of them) have namespaces set to '' (blank). This 
> causes the other party's XML processing to blow up with the error that 
> the element with the blank namespace isn't in the E-file namespace, like 
> it's supposed to be.
>
> If the namespace is set in the template, then I would expect it work 
> correctly when I've read that document in and set the namespaces 
> accordingly. That's not happening and some elements in the DOM are being 
> "taken out" of the default namespace.
>
> Can someone shed some light on why this is happening?
>
>   





------------------------------

Message: 5
Date: Mon, 27 Aug 2007 16:02:22 -0500
From: Jon Brisbin <[EMAIL PROTECTED]>
Subject: Re: [dom4j-user] Namespaces become blank when inserting or
    updating elements
To: dom4j-user@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Evan Kirkconnell wrote:
> Are you creating the problem elements with code or are they in your 
> loaded document?
>   
The problem elements are the direct descendants of the element I add the 
namespace to.

I created a test case to see what's going on. It seems to be related to 
the SAXContentHandler creating the DOM4J Document for me.

When I create the DOM4J document by reading in an XML file using the 
SAXContentHandler, the default namespace gets stripped off. Here's the 
file I read in:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:bogus-namespace">
    <first-level>
        <second-level>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
        </second-level>
        <second-level>
            <third-level>VALUE</third-level>
            <third-level>
                <data>VALUE</data>
                <data>VALUE</data>
            </third-level>
        </second-level>
    </first-level>
</root>

I read the XML file into a DOM4J Document:

String NS = "urn:bogus-namespace";
Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put( "", NS );

DocumentFactory df = DocumentFactory.getInstance();
df.setXPathNamespaceURIs( namespaces );

SAXContentHandler ch = new SAXContentHandler();
p.parse( ClassLoader.getSystemResourceAsStream( "dom4j-test.xml" ), ch );

Document d = ch.getDocument();
System.out.println( d.asXML() );

When I printed out the document, the default namespace gets stripped off:

<?xml version="1.0" encoding="UTF-8"?>
<root>
    <first-level>
        <second-level>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
        </second-level>
        <second-level>
            <third-level>VALUE</third-level>
            <third-level>
                <data>VALUE</data>
                <data>VALUE</data>
            </third-level>
        </second-level>
    </first-level>
</root>


So I added the namespace back in on the root element and tried it again:

d.getRootElement().addNamespace( "", NS );


Which manifested the problem:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="urn:bogus-namespace">
    <first-level xmlns="">
        <second-level>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
            <data>VALUE</data>
        </second-level>
        <second-level>
            <third-level>VALUE</third-level>
            <third-level>
                <data>VALUE</data>
                <data>VALUE</data>
            </third-level>
        </second-level>
    </first-level>
</root>


When I read the document in using the internal Java 1.5 Xerces parser, 
then used the DOM4J DOMReader to create a Document out of the XML file, 
everything works as expected and the default namespace is preserved like 
I expect.

I've since changed my application to use a DOMReader and have abandoned 
the SAXContentHandler as a method for creating DOM4J Documents from 
files. Using a W3C DOM first seems a little unnecessary, but if that's 
what I've got to do...

-- 


Thanks!

Jon Brisbin
Portal Webmaster
NPC International, Inc.
http://www.npcinternational.com





------------------------------

Message: 6
Date: Mon, 27 Aug 2007 16:41:31 -0500
From: Evan Kirkconnell <[EMAIL PROTECTED]>
Subject: Re: [dom4j-user] Namespaces become blank when inserting or
    updating elements
To: dom4j-user@lists.sourceforge.net
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

An HTML attachment was scrubbed...

------------------------------

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

------------------------------

_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user


End of dom4j-user Digest, Vol 15, Issue 1
*****************************************







       
____________________________________________________________________________________
Pinpoint customers who are looking for what you sell. 
http://searchmarketing.yahoo.com/
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to