[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Attempting *not* to copy certain nodes

Subject: Re: [xsl] Attempting *not* to copy certain nodes
From: 3rett 3onfield <brett@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Jan 2004 12:26:31 -0500

Thanks primarily to members of this list, I've been making good progress in my attempts to apply a XSLT stylesheet to a SOAP download of NYSE, Amex, and NAQDAQ stock information. I really appreciate your guidance.

FWIW, I've found Treebeard ( http://treebeard.sourceforge.net/ ) a very useful tool, easy to install and start using. So far I've also made some use of Cooktop ( http://www.xmlcooktop.com/ ) though I'd prefer to use an open source editor. If anyone has one they find as useful, please post (I've checked Sourceforge, list archives, usenet...).

My goal is to copy to a CSV file the Symbol, CIK, Cusip, and Market
data from the following source file:


<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="CopySuccessSoap.xslt"?>
<Message>No match found for this security identifier.</Message>
<CategoryOrIndustry />
<Name>American Biltrite Inc</Name>
<CategoryOrIndustry>Fabricated Plastic &amp; Rubber</CategoryOrIndustry>




Based on suggestions from members of this list and Google searches I've been able to create the following XSLT:


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:output method="text" indent="yes" encoding="UTF-8"/>

<xsl:template match="/">
  <xsl:apply-templates select="soap:Envelope/soap:Body/node()"/>

<xsl:template match="*"> <!--synthesize element with the input name-->
  <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
    <xsl:copy-of select="@*"/>

    <xsl:template match="/">
	<xsl:for-each select="MapSecuritiesResult/Security">
		<xsl:if test="Outcome='Success'">
		<xsl:copy-of select="Name"/>, <!--
		--><xsl:copy-of select="Symbol"/>, <!--
		--><xsl:copy-of select="CIK"/>, <!--
		--><xsl:copy-of select="Cusip"/>, <!--
		--><xsl:copy-of select="Market"/>


The code that suppresses the soap namespace is from G. Ken Holman's post:

Unfortunately, this seems to generate errors in Saxon (Treebeard's processor), IE, and Firebird. Ken uses semicolons when declaring namespaces, other places they don't ( http://www.xml.com/pub/a/2001/04/04/trxml/ ), but both (or, of course, something else I'm doing wrong) generate errors such that I get no output.

The other problem I've run into is the <xsl:text>&#13;</xsl:text> (line feed, necessary for the CSV) works in Treebeard's Saxon output window but does not work properly with Firebird or IE. Is there a way around this?

Sorry for the long post. Again, thank you for making this list public and for the help I've already received.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

Current Thread