At 2004-01-15 20:20 -0500, 3rett 3onfield wrote:
Date: Thu, 15 Jan 2004 07:07:37 -0500
From: "G. Ken Holman" <gkholman(_at_)CraneSoftwrights(_dot_)com>
Subject: RE: [xsl] Attempting *not* to copy certain nodes
At 2004-01-14 21:31 -0500, 3rett 3onfield wrote:
...
Change the second to match the response element and see what happens.
Note that in order to match the response element, and I now see for every
other element in your message body, that you'll have to add a namespace prefix.
It is a FAQ that unprefixed element and attribute names in XPath only match
constructs in no namespace. In your input message you are using a
namespace through the default namespace mechanism. XPath 1.0 never uses
the default namespace.
Below is your example modified with namespace prefixes where required by
XPath, being run by Saxon.
I hope this helps.
................... Ken
t:\ftemp>type brett.xml
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="CopySuccessSoap.xslt"?>
<soap-env:Envelope
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap-env:Body>
<MapSecuritiesResponse
xmlns="http://www.xignite.com/services/">
<MapSecuritiesResult>
<Security>
<Outcome>RequestError</Outcome>
<Message>No match found for this security identifier.</Message>
<Identity>Header</Identity>
<Delay>7.90625</Delay>
<Symbol>AA^</Symbol>
</Security>
<Security>
<Outcome>Success</Outcome>
<Delay>0</Delay>
<CIK>0001099290</CIK>
<Cusip>00371F206</Cusip>
<Symbol>AAC</Symbol>
<Name>ABLEAUCTIONS COM INC</Name>
<Market>AMEX</Market>
<CategoryOrIndustry />
</Security>
....
</MapSecuritiesResult>
</MapSecuritiesResponse>
</soap-env:Body>
</soap-env:Envelope>
t:\ftemp>type brett.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:svcs="http://www.xignite.com/services/"
exclude-result-prefixes="soap-env"
version="1.0">
<xsl:output method="text" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates select="soap-env:Envelope/soap-env:Body/node()"/>
</xsl:template>
<xsl:template match="*"> <!--synthesize element with the input name-->
<xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="svcs:MapSecuritiesResponse">
<xsl:for-each select="svcs:MapSecuritiesResult/svcs:Security">
<xsl:if test="svcs:Outcome='Success'">
<xsl:copy-of select="svcs:Name"/>, <!--
--><xsl:copy-of select="svcs:Symbol"/>, <!--
--><xsl:copy-of select="svcs:CIK"/>, <!--
--><xsl:copy-of select="svcs:Cusip"/>, <!--
--><xsl:copy-of select="svcs:Market"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
t:\ftemp>saxon -o brett.txt brett.xml brett.xsl
t:\ftemp>type brett.txt
ABLEAUCTIONS COM INC, AAC, 0001099290, 00371F206, AMEX
t:\ftemp>
--
North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide: please contact us for the details
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6 Definitive XSLT and XPath
ISBN 0-13-140374-5 Definitive XSL-FO
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners: http://XMLGuild.info
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list