Convert lowercase values to Chinese uppercase values using XSL

Source: Internet
Author: User
Tags xsl

Use specific formats such as <XSL: Number Format = "& # x58f9"/> In MSXML to convert lowercase values to uppercase values. However, when the XSL parser does not support this type of conversion, only one integer can be obtained.

The following XSL can be used to convert a value to uppercase or to RMB.

<? XML version = "1.0" encoding = "gb2312"?>
<XSL: stylesheet version = "1.0" xmlns: XSL = "http://www.w3.org/1999/XSL/Transform">
<XSL: Output encoding = "gb2312" method = "html"/>
<! -- Only two decimal places are processed when the renminbi is converted to uppercase, and the third decimal places are rounded up. -->
<! --
Copyright copyright ye jiansheng yjs_lh@sohu.com Co., yjs_lh@sina.com.
@ Version 1.0 2005.03.26 on Nanping, Chongqing
-->
<XSL: Template Name = "RMB">
<XSL: Param name = "value"/>
<XSL: Choose>
<XSL: When test = "contains ($ value, '.')">
<XSL: If test = "translate (substring-before ($ value, '.'), '0 ','')! = ''">
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "substring-before ($ value, '.')"/>
</XSL: Call-template>
<XSL: Text> meta </XSL: Text>
</XSL: If>
<XSL: variable name = "D" select = "round (substring-after (Concat ($ value, '000 '),'. '), 1, 3) Div 10) "/>
<XSL: variable name = "d1" select = "floor ($ D Div 10)"/>
<XSL: variable name = "D2" select = "$ D mod 10"/>
<XSL: If test = "$ D1 & gt; 0">
<XSL: Call-Template Name = "upperchar">
<XSL: With-Param name = "value" select = "$ d1"/>
</XSL: Call-template>
<XSL: Text> corner </XSL: Text>
</XSL: If>
<XSL: If test = "$ D2 & gt; 0">
<XSL: Call-Template Name = "upperchar">
<XSL: With-Param name = "value" select = "$ D2"/>
</XSL: Call-template>
<XSL: Text> minute </XSL: Text>
</XSL: If>
<XSL: If test = "not ($ D2) or $ D2 = 0"> integer </XSL: If>
</XSL: When>
<XSL: otherwise>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "$ value"/>
</XSL: Call-template>
<XSL: Text> meta-integer </XSL: Text>
</XSL: otherwise>
</XSL: Choose>
</XSL: Template>
<! --
At least 16 integers can be processed without precision loss.
-->
<! -- If the value is in uppercase, the input parameters are rounded to an integer. -->
<XSL: Template Name = "toupperchstr">
<XSL: Param name = "value"/>
<XSL: variable name = "v" select = "round ($ value)"/>
<XSL: Choose>
<XSL: When test = "$ V & lt; 0">
<XSL: Text> negative </XSL: Text>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "$ v *-1"/>
</XSL: Call-template>
</XSL: When>
<XSL: When test = "$ V = 0"> zero </XSL: When>
<XSL: When test = "string-length ($ value) & gt; 8">
<XSL: If test = "translate (substring ($ value, 1, string-length ($ value)-8), '0 ','')! = ''">
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "substring ($ value, 1, string-length ($ value)-8)"/>
</XSL: Call-template>
<XSL: Text> hundreds of millions </XSL: Text>
</XSL: If>
<XSL: variable name = "S" select = "substring ($ value, string-length ($ value)-7)"/>
<XSL: If test = "number ($ s) & gt; 0">
<XSL: If test = "translate (substring ($ value, 1, string-length ($ value)-8), '0 ','')! = ''And substring ($ S, 1,1) = '0'"> zero </XSL: If>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "$ s"/>
</XSL: Call-template>
</XSL: If>
</XSL: When>
<XSL: When test = "string-length ($ v) & gt; 4">
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "substring ($ V, 1, string-length ($ V)-4)"/>
</XSL: Call-template>
<XSL: Text> 10 thousand </XSL: Text>
<XSL: variable name = "S" select = "substring ($ V, string-length ($ V)-3)"/>
<XSL: If test = "number ($ s) & gt; 0">
<XSL: If test = "substring ($ S, 1,1) = '0'"> zero </XSL: If>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "$ s"/>
</XSL: Call-template>
</XSL: If>
</XSL: When>
<XSL: otherwise>
<XSL: Call-Template Name = "upperchar">
<XSL: With-Param name = "value" select = "substring ($ V, 1, 1)"/>
</XSL: Call-template>
<XSL: Call-Template Name = "getweightname">
<XSL: With-Param name = "value" select = "string-length ($ v)"/>
</XSL: Call-template>
<XSL: variable name = "V1" select = "number (substring ($ V, 2)"/>
<XSL: If test = "$ V1 & gt; = 1">
<XSL: If test = "substring ($ V, 2, 1) = '0'">
<XSL: Choose>
<XSL: When test = "string-length ($ v) & gt; 5 and $ V1 & lt; 10000"> </XSL: When>
<XSL: otherwise> zero </XSL: otherwise>
</XSL: Choose>
</XSL: If>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "$ V1"/>
</XSL: Call-template>
</XSL: If>
</XSL: otherwise>
</XSL: Choose>
</XSL: Template>
<! -- Convert the value directly into uppercase text -->
<XSL: Template Name = "upperchar">
<XSL: Param name = "value"/>
<XSL: value-of select = "translate ($ value, '123456', 'zero errors, random errors ')"/>
</XSL: Template>
<! -- Get the Chinese bit name of a bit -->
<XSL: Template Name = "getweightname">
<XSL: Param name = "value"/>
<XSL: Choose>
<XSL: When test = "$ value mod 4 = 2"> pick up </XSL: When>
<XSL: When test = "$ value mod 4 = 3"> duration </XSL: When>
<XSL: When test = "$ value mod 4 = 0"> duration </XSL: When>
<XSL: otherwise/>
</XSL: Choose>
</XSL: Template>
 
<! -- Used for testing -->
<XSL: template match = "/">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> case-to-case function </title>
</Head>
<Body>
<Table border = "1">
<Tbody>
<Tr>
<TH> original value </Th>
<TH> Chinese value </Th>
<TH> capital </Th>
</Tr>
<XSL: For-each select = "// I">
<Tr>
<TD>
<XSL: value-of select = "."/>
</TD>
<TD>
<XSL: Call-Template Name = "toupperchstr">
<XSL: With-Param name = "value" select = "."/>
</XSL: Call-template>
</TD>
<TD>
<XSL: Call-Template Name = "RMB">
<XSL: With-Param name = "value" select = "."/>
</XSL: Call-template>
</TD>
</Tr>
</XSL: For-each>
</Tbody>
</Table>
</Body>
</Html>
</XSL: Template>
</XSL: stylesheet>

XML for testing:

<? XML version = "1.0" encoding = "gb2312"?>
<Root>
<I> 1 </I>
<I> 10 </I>
<I> 100 </I>
<I> 1000 </I>
<I> 10000 </I>
<I> 100000 </I>
<I> 1000000 </I>
<I> 10000000 </I>
<I> 100000000 </I>
<I> 1000000000 </I>
<I> 10000000000 </I>
<I> 100000000000 </I>
<I> 1000000000000 </I>
<I> 10000000000000 </I>
<I> 100000000000000 </I>
<I> 1000000000000000 </I>
<I> 10000000000000000 </I>
<I> 100000000000000000 </I>
<I> 1000000000000000000 </I>
<I> 10000000000000000000 </I>
<I> 100000000000000000000 </I>
<I> 0000000000000000000000 </I>
<I> 00000000001000000000000 </I>
<I> 000000000000000100000000 </I>
<I> 00000000000000000100000000 </I>
<I> 000000000000000000100000000 </I>
<I> 0000000000000000000100000000 </I>
<I> 00000000000000000000100000000 </I>
<I> 000000000000000000000100000000 </I>
<I> 00000000000000000000000000000001 </I>
<I> 10000000000000000000001000000000 </I>
<I> 1000000000000000000000100000000 </I>
<I> 100000000000000000000010000000 </I>
<I> 10000000000000000000001000000 </I>
<I> 1000000000000000000000100000 </I>
<I> 100000000000000000000010000 </I>
<I> 10000000000000000000001000 </I>
<I> 1000000000000000000000100 </I>
<I> 100000000000000000000010 </I>
<I> 00000200000000000000011 </I>
<I> 0000000000000000000001 </I>
<I> 000000000000000010000 </I>
<I> 000000000000000000001 </I>
<I> 10000100000000000001 </I>
<I> 1000001000000000001 </I>
<I> 100200000000000001 </I>
<I> 10000000000000001 </I>
<I> 1010000000000001 </I>
<I> 100000001000001 </I>
<I> 10001000000001 </I>
<I> 1000000010001 </I>
<I> 100101001010 </I>
<I> 10000010001 </I>
<I> 1000000001 </I>
<I> 100000001 </I>
<I> 10000001 </I>
<I> 1000001 </I>
<I> 100001 </I>
<I> 10001 </I>
<I> 1001 </I>
<I> 101 </I>
<I> 11 </I>
<I> 9 </I>
<I> 123456789 </I>
<I>-123456789 </I>
<I> 12313.123 </I>
<I> 12313.125 </I>
<I> 12313.1236 </I>
<I> 12313.001 </I>
<I> 12313.005 </I>
<I> 12313.501 </I>
<I> 12313.606 </I>
<I> 00.606 </I>
<I> 0.006 </I>
<I> 5.606 </I>
<I> 10012301 </I>
<I> 012010 </I>
</Root>

Output result:

Original Value

Chinese value

RMB capital

1

Yi

Yuan 1

10

Yi pick

Yuan collection

100

Yixiao

Yiyunyuan

1000

Yixiao

Yiyunyuan

10000

Yiwan

RMB 1 million

100000

Yiqiwan

RMB

1000000

Tens of thousands

Tens of thousands of RMB

10000000

Tens of thousands

Tens of thousands of RMB

100000000

YiYi

Billion RMB

1000000000

Million

A hundred million RMB

10000000000

Hundreds of millions

YiYi billion RMB

100000000000

Million

One million RMB

1000000000000

Trillion

RMB 1 trillion

10000000000000

1 trillion

A trillion RMB

100000000000000

1 trillion

RMB 1 trillion

1000000000000000

1 trillion

RMB 1 trillion

10000000000000000

Billion

Billion RMB

100000000000000000

One billion

Billion RMB

1000000000000000000

Hundreds of millions

Billion RMB

10000000000000000000

Hundreds of millions

Billion RMB

100000000000000000000

Hundreds of millions

Billion RMB

0000000000000000000000

Zero

Zero RMB

00000000001000000000000

Trillion

RMB 1 trillion

000000000000000100000000

YiYi

Billion RMB

00000000000000000100000000

YiYi

Billion RMB

000000000000000000100000000

YiYi

Billion RMB

0000000000000000000100000000

YiYi

Billion RMB

00000000000000000000100000000

YiYi

Billion RMB

000000000000000000000100000000

YiYi

Billion RMB

00000000000000000000000000000001

Yi

Yuan 1

10000000000000000000001000000000

Million CNY and CNY

Million CNY

1000000000000000000000100000000

Billion and million

YiYi million CNY

100000000000000000000010000000

Hundreds of millions of CNY and tens of thousands of CNY

Hundreds of millions of CNY and tens of millions of CNY

10000000000000000000001000000

Trillions of billions of millions and hundreds of millions

Million, million, million

1000000000000000000000100000

One million, one million

Yi Qi Yuan

100000000000000000000010000

Yi Wan

Million CNY/CNY

10000000000000000000001000

Yi Cheng

Million CNY

1000000000000000000000100

YiYi Yiyi

YiYi Yiyi yiyuan

100000000000000000000010

YiYi billion

Million CNY collection

00000200000000000000011

Million CNY

Collect RMB million CNY

0000000000000000000001

Yi

Yuan 1

000000000000000010000

Yiwan

RMB 1 million

000000000000000000001

Yi

Yuan 1

10000100000000000001

One million, one million, one trillion

Yi Ge Fu yi yuan

1000001000000000001

One million, one trillion, one million

One million CNY and one trillion CNY

100200000000000001

One hundred million and one trillion

One hundred million and one million RMB

10000000000000001

Million and million

RMB million and RMB million

1010000000000001

One Shard, one Shard, one trillion shard

One Shard, one Shard, one trillion shard

100000001000001

One million, one trillion, one million, one million

1 million CNY, 1 million CNY, 1 million CNY

10001000000001

One hundred thousand and one hundred thousand

One million and one million CNY

1000000010001

1 trillion, 0 million, 0 million

RMB 1 trillion and RMB 1 million

100101001010

Yi Wan yi

Yi Wan yi Min yi

10000010001

YiYi Yi 0 0 0 0 0 1

Yi Wan Yi Yuan

1000000001

Million items

One hundred million CNY

100000001

Yi, yi

YiYi, Yiyi, yiyuan

10000001

Yichen

RMB million and RMB million

1000001

Yichen

RMB million and RMB million

100001

One pick ten thousand

Ten thousand yuan and one dollar

10001

Yiwanqianyi

RMB 1 million and RMB 1 million

1001

Yi, yi

Yi Yuan whole

101

Yi, yi

Yi Yuan whole

11

Yi Qianyi

Yuan collection

9

Bytes

Yuan/hour

123456789

Hundreds of millions of users

Hundreds of millions of yuan

-123456789

Hundreds of millions of customers have been picked up

Even one hundred million yuan worth of Yuan

12313.123

Hundreds of millions of users

Tens of thousands of users

12313.125

Hundreds of millions of users

Tens of thousands of yuan

12313.1236

One pick up hundreds of millions

Tens of thousands of users

12313.001

Hundreds of millions of users

Tens of thousands of yuan

12313.005

Hundreds of millions of users

Tens of thousands of yuan

12313.501

Hundreds of millions of users

Tens of thousands of yuan

12313.606

Hundreds of millions of users

Ten thousand Yuan Lu Jiao yi

00.606

Yi

Luangyi

0.006

Zero

Score 1

5.606

Lu

Wu Yuan luangyi

10012301

Yi, yi

One Shard, one million RMB, one Shard, one Shard, one shard

012010

Ten thousand others

Tens of thousands of yuan

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.