在IntelliJ中使用XSLT2.0
IntelliJ从10.5开始支持XSLT2.0,不过需要在项目中添加Saxon的库,本文介绍配置过程。
首先是下载IntelliJ社区版:
http://www.jetbrains.com/idea/
下载完成后,启动IntelliJ,创建新项目:
选择"Create project from scratch":
将项目命名为xslt2demo:
最后点Finish:
这样就新建了一个名为xslt2demo的项目,接下来新建两个文件,分别为demo.xsl和text.xml:
text.xml的文件内容为:
<?xml version="1.0"?><PLAY> <TITLE>The Tragedy of Othello, the Moor of Venice</TITLE> <TEXT> <P>ASCII text placed in the public domain by Moby Lexical Tools, 1992.</P> <P>SGML markup by Jon Bosak, 1992-1994.</P> <P>XML version by Jon Bosak, 1996-1999.</P> <P>The XML markup in this version is Copyright © 1999 Jon Bosak. This work may freely be distributed on condition that it not be modified or altered in any way. </P> </TEXT></PLAY>
<?xml version="1.0" encoding="iso-8859-1"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <wordcount> <xsl:for-each-group group-by="." select="for $w in //text()/tokenize(., '\W+')[.!=''] return lower-case($w)"> <xsl:sort select="count(current-group())" order="descending"/> <word word="{current-grouping-key()}" frequency="{count(current-group())}"/> </xsl:for-each-group> </wordcount> </xsl:template></xsl:stylesheet>
Unsupported XSL element 'http://www.w3.org/1999/XSL/Transform:for-each-group