XSLT“关联”阵列 [英] XSLT "associative" arrays

查看:46
本文介绍了XSLT“关联”阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个代码列表,我想把它翻译成一些东西

可以理解。有没有像哈希表这样的机制可以处理这个问题? (例如PHP:数组(''F''=>'''Foo'',''C''=>'''Cat''))


它只是似乎一个页面值if-tests将是一个相当笨拙的解决方案(有很多代码)问题。


基本上,我有一个XML文档看起来像

这个:

< Element T =" F"> .....< / Element>


...我希望它转换为代码的相应描述性

名称,如此(F ==> Foo):

< NewElement DN =" Foo"> .....< / NewElement>

所有的消费赞赏!

-

问候。

Audun

解决方案

Audun R?e写道:



我有一个代码列表,我想把它翻译成可以理解的。是否有一种机制,如哈希表,可以处理这个? (例如PHP:数组(''F''=>'''Foo'',''C''=>'''Cat''))

它看起来好像是一个if-tests的页面值将是一个相当笨拙的解决方案(有很多代码)问题。

基本上,我有一个XML文档看起来像< br:>这个:
<元素T =" F"> .....< /元素>

..我希望它转化为代码''相应的描述性名称,如此(F ==> Foo):
< NewElement DN =" Foo"> .....< / NewElement>

所有的sugestions赞赏!

-
问候。
Audun







我认为更好的方法是定义类似这个片段

stylesheet的内容,并将其导入主样式表:


<?xml version =" 1.0"编码= QUOT; ISO-8859-1" ?>

< xsl:stylesheet version =" 1.0"

xmlns:xsl =" http://www.w3.org/1999/XSL /转换

xmlns:date =" http://www.foo.com/Processing/dates">


< date:month -names>

< date:month short =" jan"> january< / date:month>

< date:month short =" feb" >二月< / date:月>

< date:month short =" mar"> march< / date:month>

< date:month short =" apr"> april< / date; month>

< date:month short =" may"> may< / date:month>

< date:month short =" jun"> june< / date:month>

< date:month short =" jul"> jully< / date:month>

< date:month short =" aug"> august< / date:month>

< date:month short =" sep"> september< / date:month>

< date:month short =" oct"> october< / date:month>

< date:month short =" nov"> november< / date:month>

< date:month short =" dec"> december< / date:month>

< / date:month-names>


< xsl:template name =" date :month-name">

<! - 从其编号返回月份名称 - >

< xsl:param name ="月" select =" 0" />

< xsl:value-of

select =" document(''')/ * / date:month-姓名/日期:月份


月份]" />

< / xsl:template>


< / xsl:stylesheet>


-

Cordialement,


///

(。)

----- ooO - (_) - Ooo -----

| Philippe Poulard |

-----------------------


Philippe Poulard< Ph **************** @ SPAMsophia.inria.fr>写道:

Audun R?e写道:


我有一个代码列表,我想把它翻译成一些东西
可理解的 。是否有一种机制,如哈希表,可以处理这个? (例如PHP:数组(''F''=>'''Foo'',''C''=>'''Cat''))
看起来好像一个页面值得if - 测试将是一个相当笨拙的解决方案(有很多代码)问题。



更好的方法,我认为,定义类似这个片段的东西
样式表,并将其导入主样式表:

<?xml version =" 1.0"编码= QUOT; ISO-8859-1" ?>
< xsl:stylesheet version =" 1.0"
xmlns:xsl =" http://www.w3.org/1999/XSL/Transform"
xmlns :date =" http://www.foo.com/Processing/dates">

< date:month-names>
< date:month short =" jan"> january< / date:month>
< date:month short =" feb"> february< / date; month>
< date:month short =" mar" > march< / date; month>
< date:month short =" apr"> april< / date:month>
< date:month short =" may">可以< / date; month>
< date:month short =" jun"> june< / date:month>
< date:month short =" jul"> jully< / date:month>
< date:month short =" aug"> august< / date:month>
< date:month short =" sep"> september< / date :月份>
< date:month sh ort =" oct"> october< / date; month>
< date:month short =" nov"> 11月< / date:month>
< date:month short = dec> december< / date:month>
< / date:month-names>

< xsl:template name =" date:month-name"> ;
< ;! - 从其编号返回月份名称 - >
< xsl:param name =" month" select =" 0" />
< xsl:value-of
select =" document('''')/ * / date:month-names / date:month


Hi,

I have a list of codes which I want translated into something
"understandable". Is there a mechanism such as hashtables that could
handle this? (eg. PHP: array(''F'' => ''Foo'', ''C'' => ''Cat''))

It just seems as if a page worth of if-tests would be a fairly clumsy
solution to this (there are a lot of codes) problem.

Basically, I have an XML-document which looks like something like
this:
<Element T="F">.....</Element>

...and I want it transformed into the code''s corresponding descriptive
name, like so (F ==> Foo):
<NewElement DN="Foo">.....</NewElement>
All sugestions appreciated!
--
Regards.
Audun

解决方案

Audun R?e wrote:

Hi,

I have a list of codes which I want translated into something
"understandable". Is there a mechanism such as hashtables that could
handle this? (eg. PHP: array(''F'' => ''Foo'', ''C'' => ''Cat''))

It just seems as if a page worth of if-tests would be a fairly clumsy
solution to this (there are a lot of codes) problem.

Basically, I have an XML-document which looks like something like
this:
<Element T="F">.....</Element>

..and I want it transformed into the code''s corresponding descriptive
name, like so (F ==> Foo):
<NewElement DN="Foo">.....</NewElement>
All sugestions appreciated!
--
Regards.
Audun



hi,

the better way, i think, is to define something like this snippet
stylesheet, and import it in your master stylesheet :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://www.foo.com/Processing/dates">

<date:month-names>
<date:month short="jan">january</date:month>
<date:month short="feb">february</date:month>
<date:month short="mar">march</date:month>
<date:month short="apr">april</date:month>
<date:month short="may">may</date:month>
<date:month short="jun">june</date:month>
<date:month short="jul">jully</date:month>
<date:month short="aug">august</date:month>
<date:month short="sep">september</date:month>
<date:month short="oct">october</date:month>
<date:month short="nov">november</date:month>
<date:month short="dec">december</date:month>
</date:month-names>

<xsl:template name="date:month-name">
<!--returns the name of the month from its number-->
<xsl:param name="month" select="0"/>
<xsl:value-of
select="document('''')/*/date:month-names/date:month


month]"/>
</xsl:template>

</xsl:stylesheet>

--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------


Philippe Poulard <Ph****************@SPAMsophia.inria.fr> writes:

Audun R?e wrote:

Hi,
I have a list of codes which I want translated into something
"understandable". Is there a mechanism such as hashtables that could
handle this? (eg. PHP: array(''F'' => ''Foo'', ''C'' => ''Cat''))
It just seems as if a page worth of if-tests would be a fairly clumsy
solution to this (there are a lot of codes) problem.



the better way, i think, is to define something like this snippet
stylesheet, and import it in your master stylesheet :

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://www.foo.com/Processing/dates">

<date:month-names>
<date:month short="jan">january</date:month>
<date:month short="feb">february</date:month>
<date:month short="mar">march</date:month>
<date:month short="apr">april</date:month>
<date:month short="may">may</date:month>
<date:month short="jun">june</date:month>
<date:month short="jul">jully</date:month>
<date:month short="aug">august</date:month>
<date:month short="sep">september</date:month>
<date:month short="oct">october</date:month>
<date:month short="nov">november</date:month>
<date:month short="dec">december</date:month>
</date:month-names>

<xsl:template name="date:month-name">
<!--returns the name of the month from its number-->
<xsl:param name="month" select="0"/>
<xsl:value-of
select="document('''')/*/date:month-names/date:month


这篇关于XSLT“关联”阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆