Ok, I found *some* help in the list archives: http://www.geocrawler.com/archives/3/8797/2002/3/0/8220162/ It was even an answer to one of my own questions!
>From that post, I think what I should do is create a prefix for the default namespace and use the prefix in my XPath expression I am passing to selectSingleNode(). If that's correct, my question now is: what's the best way to get the default namespace URI from a Document? -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of David Hooker Sent: Wednesday, September 04, 2002 6:03 PM To: 'DOM4J-user (E-mail)' Subject: [dom4j-user] selectSingleNode() and namespaces Hi- Two questions: (1) Ok, I have about a dozen places througout my system where I call Document.selectSingleNode("some xpath"). This has been working fine since the XML I've been processing has no default namespace. (I'm assuming that "default namespace" is a xmlns="..." attribute in the root element.) Now, all of the sudden, I'm getting a document that has a root element with a xmlns="something" attribute, and all my selectSingleNodes are returning zilch. How can I compensate for this... without having to bother with creating namespace contexts and such... with as little change to my code as possible? ==== (2) As a related question, the XML I'm processing is actually the output of a transform which I read back into a dom4j Document, do some things, then write to XML using Document.asXML(). It is this call that is writing the xmlns attribute to the root element. Why? Here's the relevant part of the xslt: <?xml version="1.0" encoding="UTF-8"?> <xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.a4networks.com/schemas/opl" xmlns:conversions="conversions.uri" exclude-result-prefixes="conversions"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*"/> ...... <xsl:template match="/"> <xsl:element name="Pip3A4PurchaseOrderRequest"> <xsl:element name="fromRole"> ...... The output looks like this: <?xml version="1.0" encoding="UTF-8"?> <Pip3A4PurchaseOrderRequest xmlns="http://www.a4networks.com/schemas/opl"> <fromRole> ...... [It is this namespace that is causing my problem in question (1) above. If I take out this xmlns attribute, all my selectSingleNode() calls work.] All help appreciated. ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user ------------------------------------------------------- This sf.net email is sponsored by: OSDN - Tired of that same old cell phone? Get a new here for FREE! https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user