• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT- Element name

 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I trying to get the element name from one document and use it for another docuement,but i get error.
<xsl:variable name="Lang" select="Message/@lang"/>
<!-- Now the Lang variable will have the value either "En" or "Fr" -->
<xsl:variable name="_1" select="document('Language.xml')/Language/$Lang/Title"/>
The output may be
"Language/En/Title" or "Language/Fr/Title"
The structure of the Language.xml is
<Language>
<En><Title>Good Day</Title></En>
<Fr><Title>Bonjour</Title></Fr>
</Language>
Is this possible. ??
Please Help me !!!
[ April 30, 2002: Message edited by: Balaji Loganathan ]
 
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunayely, XSLT processor wont replace $Lang with its value in
<xsl:variable name="_1" select="document('Language.xml')/Language/$Lang/Title"/>
There is an idiom to achieve what you want:
<xsl:variable name="_1" select="Language/*[name()=$Lang]/Title"/>
I myself wondered why "../Language/$Lang/Title" doesn't work, and it's a deep theoretic question. If I find the asnwer, I'll post it here
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mapraputa,
Its worked for me. Here is the link on Unicode characters http://home-4.tiscali.nl/~t876506/EntitiesXHTML1.html, I have one doubt on this. Is it possible to specify all the characters in Unicode,For example french letter � can be specified using & # 2 5 2;,simillary is it possible to specify the chinese and japanese characters as well.
Regards
Balaji.
[ May 01, 2002: Message edited by: Balaji Loganathan ]
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mapraputa Is:
I myself wondered why "../Language/$Lang/Title" doesn't work, and it's a deep theoretic question. If I find the asnwer, I'll post it here


That is no mystery. You just can't replace the
NCName that is required as nametest in the step with $Lang's string. Think of them as different data types.
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it possible to specify all the characters in Unicode,
Not all characters, here is Jim Yingst's favorite link to the Unicode symbols allowed in XML documents.
simillary is it possible to specify the chinese and japanese characters as well.
I am sure Chinese and Japanese characters, like any other Letters, are allowed.
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ingo Schildmann:
That is no mystery. You just can't replace the
NCName that is required as nametest in the step with $Lang's string. Think of them as different data types.


Mystery for me lies in "why", in this case "why not"? $Lang is an expression, and expressions are allowed in XPath steps. "name()=$Lang" construction has almost the same meaning, it is simply written differently. The only difference is that $Lang expression could potentially span hierarchical levels, when name() refers to the current level only. XSLT processor is perfectly capable to evaluate $Lang expression, it does it in attribute-value templates. We can write <xsl:element name="{$Lang}"/> for example. It just doesn't convert Strings to nodes and "live" XPath expressions.
This absence of dynamic evaluation features is unusual for "small" languages, and this is why I called it "mystery".
The best explanation I could find says something vague about "implications on the run-time architecture of the processor" and hints that this could hamper processor's ability to do static optimization:
"14.5 Dynamic XPath Expressions
In certain circumstances, it is useful in a stylesheet to evaluate XPath expressions that are not hard-coded in the stylesheet text. For example, XPath expressions may be read from the source document, or supplied to the stylesheet as parameters, or constructed as a string from run-time information. A common requirement is for an application to allow the user to select the key that should be used for sorting output, and a natural mechanism for implementing this is to allow the sort key to be passed to the stylesheet as a string parameter, with the string containing an XPath expression to be used as the sort key.
Issue (evaluate-function): There is at present no consensus within the working group that such a function should be provided, as it has significant implications on the run-time architecture of the processor, as well as the ability to do static optimization."
XSL Transformations (XSLT) Version 2.0 (Working Draft)
Maybe "static optimization" is the explanation.
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mapraputa,
Well I made small research on this unicode,i checked the Jim favorite site as well.I understand something.Now i'm half baked .
Basically I want to display my xml in different langauges using XSLT.(I use both XSL and XSL:FO),I believe to do it by representing other languages letters in Unicode,because xalan can understand only english letters
1.For example: english letters have & # x 0 0 4 1 ; => 'A' and & # x 0 0 4 2 ; => 'B'
2.Simillary where can i get unicode equivalent list for other languages letters.Does other language unicode falls under UTF-8 because XALAN is not supporting UTF-16.
3.Give me some URL or some suggestions.
If you look at my Language.xml structure in my first question, you will understand what i trying to do.
Show me some light.
Regards
Balaji.


Originally posted by Mapraputa Is:
Is it possible to specify all the characters in Unicode,
Not all characters, here is Jim Yingst's favorite link to the Unicode symbols allowed in XML documents.
simillary is it possible to specify the chinese and japanese characters as well.
I am sure Chinese and Japanese characters, like any other Letters, are allowed.


[ May 07, 2002: Message edited by: Balaji Loganathan ]
 
Mapraputa Is
Leverager of our synergies
Posts: 10065
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
because xalan can understand only english letters
Are you sure? By specifications, each parser has to understand UTF-8 and UTF-16 encodings.
Simillary where can i get unicode equivalent list for other languages letters. .
Unicode official site is pretty good. Here is their chart: http://www.unicode.org/charts/
Does other language unicode falls under UTF-8 because XALAN is not supporting UTF-16.
Unicode defines only symbols and their "logical" codes. How these codes are represented on bite/byte level is up to implementations - UTF8, UTF16, UTF32... All these encoding are able to represent full Unicode repertoire. Here is a good article about it:
http://www-106.ibm.com/developerworks/library/utfencodingforms/index.html
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic