Is it possible to transform an attribute from "book1chapter2" into "chapter2" ?
For example this node:
<a myAttribute="part1chapter2" />
Should be transform into
<a myAttribute="chapter2" />
I tried:
<xsl:variable name="chapter" select="replace('part1chapter2', 'book1', '')" />
But it results in an compile error:
ERROR: 'Error checking type of the expression 'funcall(replace, [literal-expr(part1chapter2), literal-expr(part1), literal-expr()])'.'
FATAL ERROR: 'Could not compile stylesheet'
I use XSLT version 2.0.
A solution without any library would be appreciate :)
EDIT:
Java code, compile and run with 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 version javac 1.6.0_27