When used from the command line, the xmllint tool doesn't accept namespaces in xpath expressions. This makes it difficult to process XML documents like the one below (file demo.xml):
<?xml version="1.0" standalone="yes"?>
<svrl:schematron-output xmlns:svrl="http://purl.oclc.org/dsdl/svrl" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:schold="http://www.ascc.net/xml/schematron" xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:iso="http://purl.oclc.org
/dsdl/schematron" title="" schemaVersion="">
<!--
-->
<svrl:active-pattern/>
<svrl:fired-rule context="/"/>
<svrl:fired-rule context="/preflight/errors/error"/>
<svrl:fired-rule context="/preflight/errors/error"/>
<svrl:failed-assert test="code != '3.1.3'" location="/preflight/errors/error[2]">
<svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text>
</svrl:failed-assert>
<svrl:fired-rule context="/preflight/errors/error"/>
<svrl:failed-assert test="code != '3.1.3'" location="/preflight/errors/error[8]">
<svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text>
</svrl:failed-assert>
<svrl:fired-rule context="/preflight/errors/error"/>
<svrl:failed-assert test="code != '3.1.9'" location="/preflight/errors/error[9]">
<svrl:text>The CIDToGID is invalid</svrl:text>
</svrl:failed-assert>
<svrl:failed-assert test="code != '3.1.11'" location="/preflight/errors/error[14]">
<svrl:text>The CIDSet entry i mandatory from a subset of composite font</svrl:text>
</svrl:failed-assert>
</svrl:schematron-output>
Solution B from Stack Overflow below:
http://stackoverflow.com/a/8266075/1209004
The example there isn't particularly clear, which is why I'm providing some additional examples based on my own example above.
xmllint --xpath "//*[local-name()='schematron-output']/*[local-name()='failed-assert']" demo.xml
Result:
<svrl:failed-assert test="code != '3.1.3'" location="/preflight/errors/error[2]">
<svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text>
</svrl:failed-assert><svrl:failed-assert test="code != '3.1.3'" location="/preflight/errors/error[8]">
<svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text>
</svrl:failed-assert><svrl:failed-assert test="code != '3.1.9'" location="/preflight/errors/error[9]">
<svrl:text>The CIDToGID is invalid</svrl:text>
</svrl:failed-assert><svrl:failed-assert test="code != '3.1.11'" location="/preflight/errors/error[14]">
<svrl:text>The CIDSet entry i mandatory from a subset of composite font</svrl:text>
</svrl:failed-assert>
xmllint --xpath "//*[local-name()='schematron-output']/*[local-name()='failed-assert']/@test" demo.xml
Result:
test="code != '3.1.3'" test="code != '3.1.3'" test="code != '3.1.9'" test="code != '3.1.11'"
xmllint --xpath "//*[local-name()='schematron-output']/*[local-name()='failed-assert']/*[local-name()='text']" demo.xml
Result:
<svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text><svrl:text>Error on the "Font File x" in the Font Descriptor</svrl:text>
<svrl:text>The CIDToGID is invalid</svrl:text><svrl:text>The CIDSet entry i mandatory from a subset of composite font</svrl:text>
xmllint --xpath "//*[local-name()='schematron-output']/*[local-name()='failed-assert']/*[local-name()='text']/text()" demo.xml
Result:
Error on the "Font File x" in the Font DescriptorError on the "Font File x" in the Font DescriptorThe CIDToGID is invalidThe CIDSet
entry i mandatory from a subset of composite font