Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: counting complex patterns

From: "Dimitre Novatchev" <dimitren@---.---.-->
To: 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
> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent