I've found a lot of topics on stackoverflow about xmllint and its "namespaces support" but none helped me.

Here is my xml (xsd to be precise) file:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema">
    <xsd:annotation>
        <xsd:documentation>My Text</xsd:documentation>
    </xsd:annotation>
</xsd:schema>

I want to retrieve "My Text" chain from this file so I try this:

xmllint myfile.xsd --xpath "/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and 
name()='schema']/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and
name()='annotation']/*[namespace-uri()='http://www.w3.org/2001/XMLSchema' and
name()='documentation']/text()"

but it doesn't work. I get "Segmentation Fault."

UPDATE

I have another question: What should I use to get my tag's attribute "toto" value in this file:

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:toto="testAtributeValue">
    <xsd:annotation>
        <xsd:documentation>myText</xsd:documentation>
    </xsd:annotation>
</xsd:schema>

To put it another way, I want to get "testAtributeValue"

有帮助吗?

解决方案

Your XML it is invalid because the "xsd" prefix is not declared (which was even reported in the command output edited out in the second .version of the question).

You want xmlns:xsd= not xmlns=.

Also name() returns a QName. You want to use local-name() to match local names.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top