[oXygen-user] Recusrive COUNT of specific elements in XSL 2.0
G. Ken Holman
gkholman at CraneSoftwrights.com
Wed Apr 18 11:58:38 CDT 2012
0At 2012-04-18 17:53 +0100, McGibbney, Lewis John wrote:
>One requirement is for me to count instances of images within a
>corpus of documents, therefore I need to get the # of images per document.
>
>I'm trying to do
>
><TotalImages value="I wish to copy the result of the below xsl:value-of here">
> <xsl:value-of select="count(SOMETHING[.])"/>
></TotalImages>
You need to use an attribute value template with brace brackets:
<TotalImages value="{XPath expression}"/>
>I know that XSLT 2.0 counts in sequences, therefore I'm hoping that
>at least my [.] is correct. As the image elements are scattered
>throughout the DOM structure so using XPath predicates is not how I
>wish to do this.
But XPath allows one to search very easily through the entire
document structure.
>We all know the typical occurrence of the relevant element --> <img
>src="blah blah" style="blahblah" etc/>
>
>Thank you in advance for any suggestions and apologies for the
>frustratingly trivial question ;0)
Can you try something along the lines of:
<TotalImages value="{count(//img)}"/>
I don't know if you are using namespaces in your source or not, so
the above might have to change.
I hope this helps.
. . . . . . . . Ken
--
Public XSLT, XSL-FO, UBL and code list classes in Europe -- May 2012
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/x/
G. Ken Holman mailto:gkholman at CraneSoftwrights.com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
More information about the oXygen-user
mailing list