xmlstarlet

Discussion in 'XML' started by Bill, Feb 16, 2008.

  1. Bill

    Bill Guest

    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>
     
    Bill, Feb 16, 2008
    #1
    1. Advertising

  2. Bill

    Joe Fawcett Guest

    "Bill" <> wrote in message
    news:...
    > 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.

    --

    Joe Fawcett (MVP - XML)

    http://joe.fawcett.name
     
    Joe Fawcett, Feb 19, 2008
    #2
    1. Advertising

  3. Bill wrote:
    > 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
     
    Hermann Peifer, Feb 19, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,450
    Mikhail Grouchinsky
    Aug 28, 2004
  2. Mikhail Grouchinsky
    Replies:
    0
    Views:
    582
    Mikhail Grouchinsky
    Sep 21, 2004
Loading...

Share This Page