Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 21st, 2006, 04:55 PM
requeth@gmail.com
Guest
 
Posts: n/a
Default Modifying variables

I have 12 possible error codes that can be placed in an attribute, and
multiple attributes with this in an XML file. I am attempting to use an
XSLT (which makes the data viewable to non technical people) to display
some statistics about these error codes. Specifically, how many of each
type there are. My thought was to create some code using variables, and
do $err01+1 (or ++), but as far as I can tell you are not allowed to
manipulate variables once called. Are any functions available that
would let me complete a count of each error type, and output them each
individually? The only bad solution I had was every time it found an
error code, create a variable +1 on the name and count them all up
after, but that's horrific to me.

Any thoughts would help,

Thanks

  #2  
Old July 21st, 2006, 07:05 PM
Joe Kesselman
Guest
 
Posts: n/a
Default Re: Modifying variables

Yes. XSLT variables are single-assignment.

The best answer is to come up with an XPath expression which finds all
the errors of a given type and ask it how long its result set is. (Use
XSLT's own counts rather than trying to compute your own.)

If you absolutely must do your own counting, you'll have to code it as a
recursive template call, using a template parameter as your counter and
calling back into the template to assign a new value to it. Can be done,
but generally ugly and inefficient and considered an absolute last resort.

See the XSL FAQ website's sections counting and numbering for some code
examples:
http://www.dpawson.co.uk/xsl/sect2/sect21.html
  #3  
Old July 21st, 2006, 08:55 PM
requeth@gmail.com
Guest
 
Posts: n/a
Default Re: Modifying variables

That was very helpful, thank you. I always love finding out a built in
function exists while I'm preparing to reinvent the wheel.

Tim :)


Joe Kesselman wrote:
Quote:
Yes. XSLT variables are single-assignment.
>
The best answer is to come up with an XPath expression which finds all
the errors of a given type and ask it how long its result set is. (Use
XSLT's own counts rather than trying to compute your own.)
>
If you absolutely must do your own counting, you'll have to code it as a
recursive template call, using a template parameter as your counter and
calling back into the template to assign a new value to it. Can be done,
but generally ugly and inefficient and considered an absolute last resort.
>
See the XSL FAQ website's sections counting and numbering for some code
examples:
http://www.dpawson.co.uk/xsl/sect2/sect21.html
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles