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/14/2005 3:06:00 PM Same as before but with a root node 'model':
****** Sample XML *******
<model>
<source id=3D"VWX" description=3D"This is VWX"/>
<source id=3D"WXY" description=3D"This is WXY"/>
<source id=3D"XYZ" description=3D"This is XYZ"/>
<reqt id=3D"VWX-01" description=3D"This is a requirement identified
within
source VWX"/>
<reqt id=3D"XYZ-01" description=3D"This is a requirement identified
within
source XYZ"/>
<reqt id=3D"XYZ-02" description=3D"This is another requirement identified
within source XYZ"/>
<package name =3D "pkg01">
<class name=3D"ABC">
<source-assoc source=3D"XYZ"/>
</class>
<class name=3D"BCD">
<reqt-assoc reqt=3D"XYZ-01"/>
</class>
<class name=3D"CDE">
<source-assoc source=3D"XYZ"/>
<reqt-assoc reqt=3D"XYZ-01"/>
<reqt-assoc reqt=3D"XYZ-02"/>
</class>
<class name=3D"DEF">
<reqt-assoc reqt=3D"VWX-01"/>
</class>
<class name=3D"EFG">
<reqt-assoc reqt=3D"XYZ-02"/>
</class>
<class name=3D"FGH">
<source-assoc source=3D"WXY"/>
</class>
</package>
</model>
*****************************
I want to count the number of classes that reference a set of sources,
e=2Eg., "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=3D"source-ids">*VWX*WXY*XYZ=AD*</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=3D"related-classes">
<xsl:for-each select=3D"package/class">
<
xsl:if test=3D".//source-assoc[contains=AD($source-ids, '*' +
@source + '*')] | .//reqt-assoc[contains($source=AD-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=AD)
Problem: I don't believe "'*' + @source + '*'" is being processed
correctly within the contains function.
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
