Search code examples
javaantxmltask

Find out wheter <?xml-stylesheet ?> node exists in xml-document


I've got a XML-document with this content:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="/Stylesheet.xsl" ?>

How can I find out using ANT's <xmltask> whether the <?xml-stylesheet ?> node already exists?


Solution

  • That's a special node type called processing instruction. You can query it using XPath to find out if it exists and what its attributes are:

    /processing-instruction('xml-stylesheet')