xmlstarlet

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bill

    xmlstarlet

    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="StockQuot e"
    targetNamespace ="http://example.com/stockquote.wsdl "
    xmlns:tns="http ://example.com/stockquote.wsdl "
    xmlns:xsd1="htt p://example.com/stockquote.xsd"
    xmlns:soap="htt p://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="TradePric eRequest">
    <complexType>
    <all>
    <element name="tickerSym bol"
    type="string"/>
    </all>
    </complexType>
    </element>
    <element name="TradePric e">
    <complexType>
    <all>
    <element name="price"
    type="float"/>
    </all>
    </complexType>
    </element>
    </schema>
    </types>

    </definitions>
  • Joe Fawcett

    #2
    Re: xmlstarlet

    "Bill" <marys.boy.chil d@comcast.netwr ote in message
    news:huqdnZmM5b BuZSvanZ2dnUVZ_ hOdnZ2d@comcast .com...
    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="StockQuot e"
    targetNamespace ="http://example.com/stockquote.wsdl "
    xmlns:tns="http ://example.com/stockquote.wsdl "
    xmlns:xsd1="htt p://example.com/stockquote.xsd"
    xmlns:soap="htt p://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="TradePric eRequest">
    <complexType>
    <all>
    <element name="tickerSym bol"
    type="string"/>
    </all>
    </complexType>
    </element>
    <element name="TradePric e">
    <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)




    Comment

    • Hermann Peifer

      #3
      Re: xmlstarlet

      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:definition s" -c "wsdl:types " short.xml

      Hermann

      Comment

      Working...