Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 10th, 2007, 10:22 PM
Registered User
 
Join Date: Sep 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Filtering Content

Hi,

Here is my xsl file:
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="no" method="text"/>

    <xsl:template match="/">

        Part Number#9;Part Description#9;Part Quantity#9;Part Find Number#9;Part Comments<xsl:text>#10;</xsl:text>
        <xsl:apply-templates select="*/*/*/Line"/>

    </xsl:template>

    <xsl:template match="Line">
        <xsl:apply-templates select="EBOMComponentName"/>
        <xsl:apply-templates select="EBOMDescription"/>
        <xsl:apply-templates select="EBOMQty"/>
        <xsl:apply-templates select="EBOMFindNumber"/>
        <xsl:apply-templates select="SeeNote"/>
        <xsl:text>
        </xsl:text>
    </xsl:template>

    <xsl:template match="EBOMComponentName">

        <xsl:if test="node()[not(.='null')]">
            <xsl:apply-templates/>
        </xsl:if>
        <xsl:text>    </xsl:text>
    </xsl:template>

    <xsl:template match="EBOMDescription">

        <xsl:if test="node()[not(.='null')]">
            <xsl:apply-templates/>
        </xsl:if>
        <xsl:text>    </xsl:text>
    </xsl:template>

    <xsl:template match="EBOMQty">

        <xsl:if test="node()[not(.='null')]">
            <xsl:apply-templates/>
        </xsl:if>
        <xsl:text>    </xsl:text>
    </xsl:template>

    <xsl:template match="EBOMFindNumber">

        <xsl:if test="node()[not(.='null')]">
            <xsl:apply-templates/>
        </xsl:if>
        <xsl:text>    </xsl:text>
    </xsl:template>

    <xsl:template match="SeeNote">

        <xsl:if test="node()[not(.='null')]">
            <xsl:apply-templates/>
        </xsl:if>
    </xsl:template>

</xsl:stylesheet>
What I can't figure out is how to only pull the records from the xml that have a value in the EBOMComponentName node. I know its something simple and I'm just missing it. It anyone can help that would be great. Thanks in advance.

 
Old September 11th, 2007, 01:56 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

.='null' compares the value of the current context with the string 'null', so unless our node actually contains the string 'null' then this will always equal false.

Have you tried "node()[.]" or "node()[empty(.)]"?

/- Sam Judson : Wrox Technical Editor -/
 
Old September 11th, 2007, 02:36 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Actually the predicate [.] will always be true when applied to a node (the node exists), and the predicate [empty(.)] will always be false (the sequence containing the node is not empty). You haven't shown the source document and it's nto entirely clear what you requirement is, but I suspect it is test="string(.)"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old September 11th, 2007, 02:54 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Oops, my bad.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use OR during filtering..... raaj81 Reporting Services 0 July 30th, 2008 05:34 AM
sorting and filtering oh my snafu7x7 XSLT 6 October 5th, 2007 10:54 AM
filtering with dates pettrer ASP.NET 2.0 Basics 1 September 13th, 2007 01:19 PM
Choosing content depending on content of other ele dsekar_nat XSLT 1 February 27th, 2006 05:58 AM
Safesquid-Content Filtering Proxy Server davidwalton Linux 1 October 15th, 2004 07:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.