Subject: Re: xsl:key From: David_Marston@xxxxxxxxx Date: Fri, 10 Mar 2000 16:00:38 -0500 |
Mike Engelhart (mengelhart@xxxxxxxxxxxxx) asks: >Does <xsl:key> require that you traverse a DOM tree every time you >use the key() function? Well, IF the second argument to key() is a singular value, and IF there is only one "row" in the keyspace matching that value, then you get a single node in return. If the second argument to key() is a union or node-set of multiple values, you still could potentially get only one node back if only one of the inputs matched, and it matched just once. Under Xalan, you don't need to take explicit action to populate the lookup table. I imagine that each XSLT processor has its own tactics to populate the table transparently. Xalan is also efficient about populating the table when it has to, which is why I suggest a keyspace for each (natural) language--it won't bother populating the tables of unused languages. The more general problem statement: >...I will know the language for the whole page. I want all text >labels, menus and buttons in the resulting HTML to be in the >language that the users browser was set to (and fall back to >English if none match). My response is to say that you want a keyspace for each language, and the first argument to key() selects the keyspace you will use to generate all labels in that language. The lookup table for every one of those parallel keyspaces will map a string input to a string output, and all the inputs will be unique in any one keyspace. You build (or at least declare) the lookup table in the xsl:key directive <xsl:key name="keyspace_name" [indicate which language] use="something" [the input side of the lookup] match="something" /> [the output side of the lookup] So if all the values of the use= nodes are unique in any one keyspace, and you call key() with a string constant for the second argument, and the match= nodes come through as string constants, then you have the effect of mapping a generic string into a string in a specific language. .................David Marston XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
xsl:key, Mike Engelhart | Thread | Re: xsl:key, Mike Engelhart |
Re: XSL Theory, Jon Smirl | Date | Netscape, Cheun N Chong |
Month |