Hi Kevin,

>Hello All,
>
>In light of the new dom4j 1.0 being released I wondered if someone could
>take the time to answer the simplest of questions.
>
>I have downloaded dom4j and have tried to work out exactly how to use it
>with no success.

Ok. Let's solve your problems :-).

>
>The examples in the cookbook state that you set up a variable of type
>"document" and then can perform functions like "SelectSingleNode".
>Unfortunately the object does NOT have those methods available... only the
>DOMDocument has those methods available (as the JavaDocs state).

Thats true a concrete instance of Document interface isn't able to apply a
XPath expression. You should do it like this:

// parse the document using SAX
Document doc = new SAXReader().read();
// create  a XPath instance
XPath xpath = DocumentHelper.createXPath("foo[@name='Kevin']");
Node node = xpath.selectSingleNode(doc);


Note that you have to cast the node into a Element or a Attribute if
desired.

I will look at the cookbook if there is an error.

>
>All I wish to be able to do is :
>
>1. Read a String containing XML into a DOM Document object
>2. Extract specific values from that string using XPath (ie
>SelectSingelNode("Name/Name") )
>3. Validate that XML string against a Schema
>4. Transform it using XSLT



2) 
Look at the above shown example.


3)
I will provide soon a chapter that should explain all you need to no to
validate a dom4j Document against XML Schema, DTD, Relax etc. Stay tuned. It will
be out tomorrow I think.

4)
There's a exellent chapter in cookbook about this. Whats your problem with
it?
DocumentSource or DocumentResult are used according TrAX Standard.
You can also review 

http://www.dom4j.org/guide.html#Styling%20a%20Document%20with%20XSLT

Maybe this helps you.

>
>Even the simplest help would be appreciated as all the examples provided in
>the cookbook fail to show the FULL connection between the objects or use
>methods that don't exist on the objects they are defined as.

I think simple and small examples would be nice to learn how to use all the
features dom4j offers. When you by a Java Beginners book you won't find a
complex Java Application in the book. But I will offer a complex sample along
with some explainations in the next version of dom4j. 
I see that you have problems understanding the modular structure of dom4j. I
will provide also a chapter that explains the this structure.
Critique about cookbook is always appricated. I just want to make things
better. But I need excat informations to do this.

Thanks
Toby

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net



_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to