<XPath xmlns:n1="http://example.net" >
    (//. | //@* | //namespace::*)
    [
	ancestor-or-self::n1:elem2
    ]
</XPath>