属性を「book1chapter2」から「chapter2」に変換することはできますか?
たとえば、このノード:
<a myAttribute="part1chapter2" />
に変換する必要があります
<a myAttribute="chapter2" />
私は試した:
<xsl:variable name="chapter" select="replace('part1chapter2', 'book1', '')" />
しかし、それはコンパイルエラーになります:
ERROR: 'Error checking type of the expression 'funcall(replace, [literal-expr(part1chapter2), literal-expr(part1), literal-expr()])'.'
FATAL ERROR: 'Could not compile stylesheet'
XSLT バージョン 2.0 を使用しています。
ライブラリのないソリューションをいただければ幸いです:)
編集:
Java コード。javac -g TestXslt.java でコンパイルおよび実行します。Java TestXslt;
public static void main(String[] args) throws IOException, URISyntaxException, TransformerException {
TransformerFactory factory = TransformerFactory.newInstance();
Source xslt = new StreamSource(new File("../transform.xslt"));
Transformer transformer = factory.newTransformer(xslt);
Source text = new StreamSource(new File("../input.xml"));
String r = new String();
StreamResult result = new StreamResult(new File("../output.xml"));
transformer.transform(text, result);
}
Java バージョン javac 1.6.0_27