[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XSLT tweak to exclude XML nodes required

Posted on 2006-05-02
2
Medium Priority
?
438 Views
Last Modified: 2012-06-27
Hello.  Hopefully this quite simple!

I am currently using the following XSLT to generate XHMTL from XML created from ADO recordsets:


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:template match="/">
        <html>
            <body>
                <table class="report">
                    <xsl:apply-templates select="selectrows"/>
                </table>
            </body>
        </html>
    </xsl:template>
   
    <xsl:template match="selectrows">
       <THEAD>
          <TR class="header">
            <xsl:for-each select="selectrow[1]/*">
                <TD align="left">

                  <xsl:call-template name="replace-string">
                    <xsl:with-param name="text" select="name(.)"/>
                    <xsl:with-param name="replace" select="'_'"/>
                    <xsl:with-param name="with" select="' '"/>
                  </xsl:call-template>
                  <!--      
                  <xsl:value-of select = "name(.)" />
                  -->

                 </TD>
            </xsl:for-each>
        </TR>
      </THEAD>
        <xsl:apply-templates select="selectrow"/>

        <!-- Put  any footer information here <TD> and </TD> -->
        <TR class="footer">
          <TD>Total rows</TD>
          <TD></TD>
          <TD class="int"><xsl:value-of select="count(//selectrow)" /></TD>
        </TR>
      
    </xsl:template>
   
    <xsl:template match="selectrow">
        <tr>
            <xsl:for-each select="*">
                <td class="char"><xsl:value-of select="."/></td>
            </xsl:for-each>
        </tr>
    </xsl:template>




  <xsl:template name="replace-string">
    <xsl:param name="text"/>
    <xsl:param name="replace"/>
    <xsl:param name="with"/>

    <xsl:choose>
      <xsl:when test="contains($text,$replace)">
        <xsl:value-of select="substring-before($text,$replace)"/>
        <xsl:value-of select="$with"/>
        <xsl:call-template name="replace-string">
          <xsl:with-param name="text"
select="substring-after($text,$replace)"/>
          <xsl:with-param name="replace" select="$replace"/>
          <xsl:with-param name="with" select="$with"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>



</xsl:stylesheet>


What I would like to do is exclude certain rows (nodes) from the report.

For example, the first row of data in the XML I call "recordnumber" and this is a simple count.  How do I modify the line:
  <xsl:for-each select="selectrow[1]/*">

To skip the "recordnumber" data from the XML?

Thanks in advance!
0
Comment
Question by:colly92002
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 200 total points
ID: 16586886
Try:

    <xsl:for-each select="selectrow[1]/*[not(name()='recordnumber')]">
0
 
LVL 15

Author Comment

by:colly92002
ID: 16586992
That seems to have worked.

Thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question