小编pin*_*her的帖子

使用区域设置将英语国家/地区名称更改为德语

我有这个要求,我需要将等效的国家/地区代码转换为德语国家/地区名称.我正在使用Locale构建器来获取代码.

这是我的代码:

我做的第一个就是:

Locale locale = new Locale("GERMANY", "AT");
Run Code Online (Sandbox Code Playgroud)

生成的输出: German (Austria)

第二个:

Locale aLocale = new Locale.Builder().setLanguage("de").setRegion("AT").build();
Run Code Online (Sandbox Code Playgroud)

生成的输出: German (Austria)

我需要的是将"AT"奥地利的countryCode转换为德语,它应该生成Österreich.

java locale

7
推荐指数
1
解决办法
925
查看次数

将字符串转换为二进制 base64

有没有办法将字符串转换为二进制 base64?我看过很多参考资料,但最终没有奏效。例如我有这个输入文件:

<RootElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     <Data>
         <Binary>
               <RawData>This element should convert string to binary base64.</RawData>
         </Binary>
    </Data>
</RootElement>
Run Code Online (Sandbox Code Playgroud)

我需要生成:

<RootElement xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Data>
    <Binary>
        <RawData>VGhpcyBlbGVtZW50IHNob3VsZCBjb252ZXJ0IHN0cmluZyB0byBiaW5hcnkgYmFzZTY0Lg==</RawData>
    </Binary>
</Data>
Run Code Online (Sandbox Code Playgroud)

我创建了一个 xslt 并使用了我在网上看到的命名空间:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dp="http://www.datapower.com/extensions">
<xsl:output method="xml" version="1.0" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>
<xsl:template match="RawData">
    <xsl:element name="RawData">
        <xsl:value-of select="dp:encode(., 'base-64')"/>
    </xsl:element>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

谢谢你。

xslt base64 xslt-2.0 xslt-1.0

0
推荐指数
1
解决办法
4136
查看次数

标签 统计

base64 ×1

java ×1

locale ×1

xslt ×1

xslt-1.0 ×1

xslt-2.0 ×1