How to check if node has one or more specific attributes with XPath in Java?
===

I would like to get every child node which contains one of the these attributes: type, ref, base. The value of each attribute doesn't matter, I just want to check if the attribute exists.

This is how I do it now:

    private void addRequiredNodeAndChildren(Node n) {    
                XPath xpath = XPathFactory.newInstance().newXPath();
    			String expression = "*//*[@base or @ref or @type]";
    			XPathExpression expr = xpath.compile(expression);
    			NodeList referList = (NodeList) expr.evaluate(n, XPathConstants.NODESET);
                ..
    }

This expression works fine but in one case I don't get all expected nodes:
   

     <xs:complexType name="ListElement">
    		<xs:annotation>
    			<xs:documentation>
    			</xs:documentation>
    		</xs:annotation>
    		<xs:attribute name="transferMode" type="myprefix:dataTransferMode"
    			use="optional">
    			<xs:annotation>
    				<xs:documentation>Documentation for attribute
    				</xs:documentation>
    			</xs:annotation>
    		</xs:attribute>
    	</xs:complexType>

I expect to get the <xs:attribute> node with the expression above, but unfortunately I don't get it. Change the expression to 

    //*[@base or @ref or @type] 

didn't help either, as a result of that I got every node from the XML with one of the attributes but I want to get only the child nodes of the given node n. I also tried 

    *//*[@base] or *//*[@ref] or *//*[@type]

as expression but that didn't work as well.

Has anyone ideas how to solve my problem?