xmlstarlet

B

Bill

Hi,

I'm trying to extract the 'types' section out of some WSDL with
xmlstarlet, using the following expression and data:

xmlstarlet sel -t -m '/definitions' -c types short.xml

As listed (without the ###) it produces nothing, but without
the xmlns line it works. Isn't 'xmlns' just disambiguating?
Why should it make such a difference?

Note, that though the below is only partial, the behavior
is the same with the full WSDL file.

Thanks much,
Bill

-- short.xml:

<?xml version="1.0"?>
<!-- the xmlns is what does it -->
<definitions
name="StockQuote"
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap"
### without the next line it works fine
xmlns="http://schemas.xmlsoap.org/wsdl"
<types>
<schema targetNamespace="http://example.com/stockquote.xsd"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>
<element name="tickerSymbol"
type="string"/>
</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price"
type="float"/>
</all>
</complexType>
</element>
</schema>
</types>

</definitions>
 
J

Joe Fawcett

Bill said:
Hi,

I'm trying to extract the 'types' section out of some WSDL with
xmlstarlet, using the following expression and data:

xmlstarlet sel -t -m '/definitions' -c types short.xml

As listed (without the ###) it produces nothing, but without
the xmlns line it works. Isn't 'xmlns' just disambiguating?
Why should it make such a difference?

Note, that though the below is only partial, the behavior
is the same with the full WSDL file.

Thanks much,
Bill

-- short.xml:

<?xml version="1.0"?>
<!-- the xmlns is what does it -->
<definitions
name="StockQuote"
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap"
### without the next line it works fine
xmlns="http://schemas.xmlsoap.org/wsdl"
<types>
<schema targetNamespace="http://example.com/stockquote.xsd"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>
<element name="tickerSymbol"
type="string"/>
</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price"
type="float"/>
</all>
</complexType>
</element>
</schema>
</types>

</definitions>

I've never used xmlstarlet but read this
http://www.dpawson.co.uk/xsl/sect2/N5536.html especially numbers 13 and 23.
Presumably xmlstarlet has some method to bind the default namespace to an
arbitrary prefix.
 
H

Hermann Peifer

Bill said:
Hi,

I'm trying to extract the 'types' section out of some WSDL with
xmlstarlet, using the following expression and data:

xmlstarlet sel -t -m '/definitions' -c types short.xml

As listed (without the ###) it produces nothing, but without
the xmlns line it works. Isn't 'xmlns' just disambiguating?
Why should it make such a difference?

I just used xmlstarlet for the first time today and came across a
similar issue. The below expression seems to work as expected:

xmlstarlet sel -N wsdl=http://schemas.xmlsoap.org/wsdl \
-t -m "/wsdl:definitions" -c "wsdl:types" short.xml

Hermann
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,233
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top