[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Length of a literal string containing embedded tag
Abel Braaksma wrote:
That would be (for the fun of it), something alongside the following (assuming the context node must be counted): sum(( descendant-or-self::text()/(string-length()), descendant-or-self::element()/(string-length(name()), string-length(name()), 5), descendant-or-self::element()/attribute::*/(string-length(name()), string-length(), 4), descendant-or-self::processing-instruction()/(string-length(name()), string-length(), 4), descendant-or-self::comment()/(string-length(), 7) )) And yes, the double parentheses around sum() are on purpose ;) Note that the last one in each selection is the minimal number of extra characters that are used in literal XML, i.e., for an attribute it requires two quotes, one whitespace (at least) and one equal sign, totaling 4. Note also that this XPath expression sees all elements as <elem>data</elem>, all texts as normal texts (no cdata, each entity as one), all whitespace as relevant and cannot count markup-whitespace etc. Cheers, -- Abel Braaksma
|
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
|