[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Excluding matches - still having problems
Hi, I now have a question (now that my exclusions are working) about my addval template. This template simply return the current submitid followed by a comma. It ignores the comma if the position of the xml document is last (don't want a trailing comma). However, since I am excluding certain submitids, if the last submitid is excluded, I end up with a trailing comma! So, the question is... how to avoid the trailing comma, or maybe there is a better place in my template to add the comma. I was thinking of adding the comma before calling the addval template (or in the beginning of the addval template), but then I'm up against the same dilemna, possibly having a leading comma. Hmmm... is there a way to determine if any output has been generated by the stylesheet, and to only lead off with a comma if there is previous output? Thanks, Karl ----- Original Message ----- From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Monday, June 30, 2003 11:31 AM Subject: Excluding matches - still having problems > Hello all, > > I'm still having trouble with my excluding matches template. I am stumped : > (. I have been through David and Wendell's suggestions, I feel I am close, > but not sure what is going wrong. > My parser, by the way is MSXML 4.0. > > I'm not sure where to go (but here). I am including all 3 sources to > review, here they are: > > XSLT DOCUMENT: > > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" > xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" > xmlns:rs="urn:schemas-microsoft-com:rowset" > xmlns:z="#RowsetSchema" > exclude-result-prefixes="s dt rs z"> > <xsl:output method="text"/> > <xsl:param name="excludes"/> > > <xsl:template match="/"> > <xsl:apply-templates select="xml/rs:data/z:row"/> > </xsl:template> > > <xsl:template match="z:row"> > <xsl:if test="not($excludes/ID=@submitid)"> > <xsl:call-template name="addval"/> > </xsl:if> > </xsl:template> > > <xsl:template name="addval"> > <xsl:value-of select="@submitid"/> > <xsl:if test="position()!=last()"> > <xsl:text>,</xsl:text> > </xsl:if> > </xsl:template> > > </xsl:stylesheet> > > XML SOURCE FOR IDS: > > <xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" > xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" > xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema"> > <s:Schema id="RowsetSchema"> > <s:ElementType name="row" content="eltOnly" rs:CommandTimeout="30"> > <s:AttributeType name="submitid" rs:number="1" rs:writeunknown="true"> > <s:datatype dt:type="int" dt:maxLength="4" rs:precision="7" > rs:fixedlength="true" rs:maybenull="false"/> > </s:AttributeType> > <s:extends type="rs:rowbase"/> > </s:ElementType> > </s:Schema> > <rs:data> > <z:row submitid="815085"/> > <z:row submitid="815260"/> > <z:row submitid="915219"/> > <z:row submitid="1010050"/> > <z:row submitid="1010051"/> > <z:row submitid="1010072"/> > <z:row submitid="1010107"/> > <z:row submitid="1010120"/> > </rs:data> > </xml> > > > =======XML SOURCE FOR ID'S TO BE EXCLUDED > > <?xml version="1.0"?> > <EXCLUDE><ID reason="User Excluded">815260</ID><ID reason="User Excluded"> > 915219</ID><ID reason="User Excluded"> 1010107</ID></EXCLUDE> > > > ... oh geez, as I post this, i do believe i see the problem (spaces in the > ID!!!). > Ugggg... I will fix the source generating script, however, what would be the > best way to fix this in my stylesheet (normalize-space)? > > Karl > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|