English 中文(简体)
wikitext到xml
原标题:wikitext to xml

是否有转换wikitext数据转换为Java应用程序中的简单XML?

输入示例:

  == A section ==
  this is some text...           

{{MyTemplate
|attr1=some value
|attr2=some other value
      ...

输出示例:

<section title= A section >this is some text...</section>
<ValueDescription attr1= some value  attr2= some other value  ...>

这似乎是一项琐碎的任务,但我找不到一个用Java做这件事的库。

Mulone

最佳回答

XML有树状结构,而wikitext在大多数情况下没有。例如,这是完全合法的:

== A section {{DoubleEqual{{echo|Sign}}}}

模板语法本身是分层的,MediaWiki本身将其转换为XML(您可以使用Special:ExpandTemplates查看),但其余语法对于xml或其他形式描述(如上下文无关语法)来说过于松散。

存在重写工作正在将wikitext变成一种标准的、可解析的语言,但不要指望它会很快结束。

问题回答

http://sweble.org/wiki/Wikitext-parser/他们有一个完成得很好的解析器,但我认为AST还没有XML输出。

@Tgr:从语法上来说,它与Tree并不真正兼容,但从语义上来说是兼容的。

是的,处理Wikitext是一团糟。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签