在Java中是否有一种简单的方法可以从给定的国家/地区名称中获取ISO2代码,例如"CH"在给定"瑞士"时?
我现在能想到的唯一解决方案是将所有国家/地区代码和名称保存在一个数组中并迭代它.还有其他(更简单的)解决方案
我正在尝试通过在phpexcel中迭代创建多个工作表:
$i=0;
while ($i < 10) {
// Add new sheet
$objWorkSheet = $objPHPExcel->createSheet();
// Attach the newly-cloned sheet to the $objPHPExcel workbook
$objPHPExcel->addSheet($objWorkSheet);
// Add some data
$objPHPExcel->setActiveSheetIndex($i);
$sheet = $objPHPExcel->getActiveSheet();
$sheet->setCellValue('A1', 'Hello'.$i)
->setCellValue('B2', 'world!')
->setCellValue('C1', 'Hello')
->setCellValue('D2', 'world!');
// Rename sheet
$sheet->setTitle($i);
$i++;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,这不起作用.我只得到一些填充了数据并重命名的迭代表,大约一半是空的.
所以这是结果(工作表标题):
0,2,4,6,8,9和5个空床单
我无法弄清楚为什么只有偶数(和表9)在结果中是正确的.
有没有可能document()在XSLT中为函数使用通配符,如:
document("*.xml")
Run Code Online (Sandbox Code Playgroud)
这是同一个问题:http://www.biglist.com/lists/xsl-list/archives/200108/msg00542.html
不过这篇文章是从2001年开始的,所以可能有任何新技术可以解决这个问题.想法?
我正在尝试在变量中创建项目列表,并且想要检查项目是否已经在列表中.这些项目由输入文档给出,这对我的问题并不重要.
所以我试图解决两个问题.
1:从我当前生成的变量中读取数据
2:将文本追加到变量中的节点
这是我到目前为止所尝试的:
<xsl:variable name="data">
<list>
<xsl:call-template name="generate"/>
</list>
</xsl:variable>
<xsl:template name="generate" match="/">
<xsl:apply-templates select="//thing"/>
</xsl:template>
<xsl:template match="//thing">
<xsl:variable name="temp">
<xsl:value-of select="./text()"/>
</xsl:variable>
<xsl:choose>
<!-- test however this thing is already in $data -->
<!-- problem #1: here, trying to read anything out of $data doesn't work -->
<xsl:when test="contains($data/list/item/text(), $temp/text())">
<xsl:for-each select="$data/list/item">
<xsl:if test="contains(./text(), $temp/text())">
<!-- problem #2: append any string to self::node()/text() -->
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<item>
<xsl:value-of name="$temp/text()"/>
</item>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
我已经搜索了很多结果树片段等等,但是没有想到如何做到这一点.
编辑:这应该是输入代码: …