XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="biblio.xsl"?>
<bibliography>
<entry type="article">
<title>A History of MOOCs, Open Online Courses</title>
<author>Jane Karr</author>
<year>2014</year>
</entry>
<entry type="article">
<title>Apple Co-Founder Creates Electronic ID Tags</title>
<author>John Markoff</author>
<year>2003</year>
</entry>
</bibliography>
Run Code Online (Sandbox Code Playgroud)
XSL 文件:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Bibliography Entries</h2>
<table border="1">
<xsl:for-each select="bibliography/entry">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/></td>
<td><xsl:value-of select="year"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
如果我不将 XSLT 文件链接到 XML 文件,我的 XML 文件将在浏览器页面中输出树结构,但如果我链接 XSLT 文件,它将显示一个空白页面。
我正在使用 Chrome,如果有帮助的话。
谢谢。
我正在尝试在Intellij中为项目配置Tomcat,但在尝试运行Tomcat之后却陷入了此错误。我不确定从这里去哪里。
我希望能够输出"=="和"="作为标记.
例如,输入文本文件是:
biscuit==cookie apple=fruit+-()
Run Code Online (Sandbox Code Playgroud)
输出:
biscuit
=
=
cookie
apple
=
fruit
+
-
(
)
Run Code Online (Sandbox Code Playgroud)
我希望输出是什么:
biscuit
==
cookie
apple
=
fruit
+
-
(
)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
Scanner s = null;
try {
s = new Scanner(new BufferedReader(new FileReader("input.txt")));
s.useDelimiter("\\s|(?<=\\p{Punct})|(?=\\p{Punct})");
while (s.hasNext()) {
String next = s.next();
System.out.println(next);
}
} finally {
if (s != null) {
s.close();
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
编辑:我希望能够保持当前的正则表达式.
我很难找到如何从文件中读取并输出分隔符,如";" 或":"等作为单独的字符串
这是我到目前为止所做的:
int i = 0;
s = new Scanner(new BufferedReader(new FileReader("lab1.txt")));
while (s.hasNext()) {
System.out.println(s.next());
i++;
Run Code Online (Sandbox Code Playgroud)
输入文件lab1.txt是:
cookies; and juice
Run Code Online (Sandbox Code Playgroud)
输出:
cookies;
and
juice
Run Code Online (Sandbox Code Playgroud)
我希望输出是什么:
cookies
;
and
juice
Run Code Online (Sandbox Code Playgroud)
知道我怎么能得到它?
谢谢.