Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: counting complex patterns >Thread Next - Re: counting complex patterns Re: counting complex patternsTo: NULL Date: 6/3/2005 7:12:00 PM Sorry, but you haven't provided a well-formed xml document. <drs58@m...> wrote in message news:1117749138.925631.253620@g...... > I'll give it another try....thanks for hanging in there with me: > > ****** Sample XML ******* > <source id="VWX" description="This is VWX"/> > <source id="WXY" description="This is WXY"/> > <source id="XYZ" description="This is XYZ"/> > <reqt id="VWX-01" description="This is a requirement identified within > source VWX"/> > <reqt id="XYZ-01" description="This is a requirement identified within > source XYZ"/> > <reqt id="XYZ-02" description="This is another requirement identified > within source XYZ"/> > <package name = "pkg01"> > <class name="ABC"> > <source-assoc source="XYZ"/> > </class> > <class name="BCD"> > <reqt-assoc reqt="XYZ-01"/> > </class> > <class name="CDE"> > <source-assoc source="XYZ"/> > <reqt-assoc reqt="XYZ-01"/> > <reqt-assoc reqt="XYZ-02"/> > </class> > <class name="DEF"> > <reqt-assoc reqt="VWX-01"/> > </class> > <class name="EFG"> > <reqt-assoc reqt="XYZ-02"/> > </class> > <class name="FGH"> > <source-assoc source="WXY"/> > </class> > </package> > ***************************** > > > I want to count the number of classes that reference a set of sources, > e.g., "XYZ and VWX", via <source-assoc/> or <reqt-assoc/> tags > ****** Desired output for XYZ and VWX ******* > 5 > ***************************** > > My approach is to: > 1) construct a variable with all source document id's concatenated and > delimited by '*', e.g., > <xsl:variable name="source-ids">*VWX*WXY*XYZ*</xsl:variable> > > 2) for each class, construct a variable by iterating through the > classes and adding a character, e.g., 'X', > every time I find a one with an appropriate <source-assoc> or > <reqt-assoc/> tag, e.g., > <xsl:variable name="related-classes"> > <xsl:for-each select="package/class"> > <xsl:if test=".//source-assoc[contains($source-ids, '*' + > @source + '*')] | .//reqt-assoc[contains($source-ids, '*' + > substring-before(@reqt, '-') + '*')]">X</xsl:if> > </xsl:for-each> > </xsl:variable> > NOTE: I want to include the delimiter in the contains function > parameter to ensure that the match is not based on a substring within a > source id > NOTE: The <source-assoc/> and <reqt-assoc/> tags might actually also > be included within elements contained within classes. > > 3) display string-length($related-classes) > > Problem: I don't believe "'*' + @source + '*'" is being processed > correctly within the contains function. > > Any help would be appreciated! > > Thanks in advance, > David > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
