Subject: Re: [xsl] Pulling out my hair: XSLT and XML with namespace From: Rob Rohan <me@xxxxxxxxxxxx> Date: 06 May 2003 18:36:48 -0700 |
> I hope I'm not repeating a post of another message in this list, but I've > looked everywhere on the net with both Google and Altavista, and cannot > figure out what is wrong with my XPath/XSLT parsing. > > Given the following XML file: > > <?xml version="1.0"?> > <definitions name="TemperatureService" > targetNamespace="http://www.xmethods.net/sd/TemperatureService.wsdl" > xmlns:tns="http://www.xmethods.net/sd/TemperatureService.wsdl" > xmlns:xsd="http://www.w3.org/1999/XMLSchema" > xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" > xmlns="http://schemas.xmlsoap.org/wsdl/"> > <service name="TemperatureService"> > <documentation>Returns current temperature in a given U.S. > zipcode </documentation> > <port name="TemperaturePort" > binding="tns:TemperatureBinding"> > <soap:address > location="http://services.xmethods.net:80/soap/servlet/rpcrouter"/> > </port> > </service> > </definitions> > > and the following XSLT snippet: > > <?xml version="1.0" encoding="utf-8"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="html"/> > <xsl:template match="/"> > > <xsl:for-each select="definitions/service/port"> > POST Path = <xsl:value-of select="soap:address/@location"/> > </xsl:for-each> > > I get the following result: > > (BLANK DOCUMENT) You are really close (dont pull your hair out - trust me you'll want ot keep it for as long as possible) The problem is the xml document has a default name space ...xmlns="http://schemas.xmlsoap.org/wsdl/"> Which (in a sense) means that <definitions> really is <{http://schemas.xmlsoap.org/wsdl/}definitions> (for give me if my syntax is wrong. What you can do is reference that name space in the xslt like so: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:booga="http://schemas.xmlsoap.org/wsdl/" > <xsl:output method="html"/> <xsl:template match="/"> <xsl:for-each select="booga:definitions/booga:service/booga:port"> POST Path = <xsl:value-of select="soap:address/@location"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> and that should yield POST Path = http://services.xmethods.net:80/soap/servlet/rpcrouter do you see why? repost if you dont. Cheers, Rob -- _/ _/_/ _/_/_/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ http://treebeard.sourceforge.net http://ashpool.sourceforge.net XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Pulling out my hair: XSLT and, Ken Shino | Thread | [xsl] How to get list of namespace , Karthickraj N - CTD, |
Re: [xsl] Newline problems, Mike Brown | Date | [xsl] Pulling out my hair: XSLT and, Ken Shino |
Month |