[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: Mon, 12 Jan 2004 09:18:21 -0500

Thank you for the suggestions--it's great to learn a new tool supported by such a thoughtful and helpful community of programmers.

I tried to use Andreas's ideas, but I suspect I didn't fully understand them. I tried cutting and pasting J.Pietschmann's code as follows:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="Security[Outcome='Success']"/>
</xsl:template>
</xsl:stylesheet>


I saved it as CopySuccess.xslt and called it from XML2Transform.xml with:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="CopySuccess.xslt"?>
<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>
  <Security>
  <Outcome>Success</Outcome>
  <Delay>0</Delay>
  <CIK>0000004611</CIK>
  <Cusip>024591109</Cusip>
  <Symbol>ABL</Symbol>
  <Name>American Biltrite Inc</Name>
  <Market>AMEX</Market>
  <CategoryOrIndustry>Fabricated Plastic &amp; Rubber</CategoryOrIndustry>
  </Security>
  <Security>
  <Outcome>Success</Outcome>
  <Delay>0</Delay>
  <CIK>0000867665</CIK>
  <Cusip>003830106</Cusip>
  <Symbol>ABP</Symbol>
  <Name>Abraxas Petroleum Corp</Name>
  <Market>AMEX</Market>
  <CategoryOrIndustry>Oil &amp; Gas Operations</CategoryOrIndustry>
  </Security>

...

</MapSecuritiesResult>

I opened XML2Transform.xml in Firebird 0.7 and IE 6.0.2800.1106.xpsp2. Both produced whitespace in the browser and when I viewed source code, neither had transformed my XML document.

BTW, the point of the exercise is to clean up a SOAP query. Using SOAP I've been able to download a complete list of identification elements for U.S. common stocks. The first stage of cleaning up the SOAP document is taking out the RequestErrors, the second is transforming the result to CSV. I plan to use the following template to achieve my results ( found here: http://tinyurl.com/2towh ):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="no"/>
<xsl:template match="root">
<xsl:apply-templates select="recordNode[1]/*" mode="fieldnames"/>
<xsl:text>&#13;</xsl:text>
<xsl:apply-templates select="recordNode"/>
</xsl:template>
<xsl:template match="recordNode" xml:space="default">
<xsl:apply-templates select="*"/>
<xsl:text>&#13;</xsl:text>
</xsl:template>
<!-- comments are simply taking the place of whitespace
for readability-->
<xsl:template match="*" mode="fieldnames"><!--
-->"<xsl:value-of select="name()"/>"<!--
--><xsl:if test="position() != last()">,</xsl:if><!--
--></xsl:template>
<xsl:template match="*"><!-- fakespace
-->"<xsl:value-of select="."/>"<!-- fakespace
--><xsl:if test="position() != last()">,</xsl:if><!--
--></xsl:template>
</xsl:stylesheet>


Finally, I've downloaded XPATH Visualizer (again, thank you for the suggestion). Coincidentally (?), there seem to be two programs called XPATH Visualizer. I downloaded the one found here: http://logilab.nerim.net/org/xpathvis/

Anyone have difficulty making it work properly with Xerxes 2.6.0 or Xalan 2.5.2? The website calls for "xalan: any version from 2.0.1 to 2.1.0 (latest stable) (see Apache web site)" and "xerces: any version from 1.2.3 to 1.4.1 (see Apache web site)," but the site was last updated 2001/09/07 23:43:31 so I'm not sure I should take it literally.

Again, thanks for pointing me in the right direction. The more I learn the more I wonder why I didn't start learning this earlier.

Brett


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




Current Thread
Keywords