使用 wiki 标记以 XML 形式存储 Web 内容
有人有一个 XML 样式表可以将类似 wiki 的标记转换为 HTML 吗?或者这是一个坏主意?我只找到了一个样式表,可以将 HTML 转换为类似 wiki 的标记,查看源代码:http://mozile.mozdev.org/0.8/demos/html2wiki.xsl。或者这是一个坏主意?基本上,我认为最好不要遵循 XML 标签的严格规则来格式化我的内容:
这样我就可以随意显示我的内容,而无需修改我的样式表。
有什么想法吗?
Does anyone have an XML style sheet that'll convert wiki-like markup to HTML? Or is that a bad idea? I only found one style sheet that'll convert HTML to wiki-like markup, view-source:http://mozile.mozdev.org/0.8/demos/html2wiki.xsl . Or is this a bad idea? Basically, instead of following strict rules with my XML tags to format my content, I thought it'd be best to have something like this:
<content>
\## This is my heading
</content>
That way I'm free to display my content however I feel without having to modify my style sheet.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
通过精心设计的 XML 和适当的样式表,您很少或永远不需要修改 XSLT 代码。
但是,XSLT 不适用于字符串处理。您不应该尝试处理这样的事情:
而是像这样:
要从 Wiki 样式文本
## 这是我的标题
到正确的 XML,您必须首先使用 XSL 以外的东西(即理解 Wiki 标记的解析器)。一旦有了正确的 XML,您就可以继续使用 XSLT。With sensibly crafted XML and a proper stylesheet you would rarely or never have to modify your XSLT code.
However, XSLT is not for string processing. You should not try to work on stuff like this:
but rather like this:
To get from Wiki style text
## This is my heading
to proper XML you would have to use something other than XSL first (i.e. a parser that understands the Wiki markup). Once you have proper XML, you can go on with XSLT.感谢您的回复,托马拉克。
我目前正在使用像你建议的那样的东西,但是,似乎我会有很多展示柜。这意味着我的 XSL 将必须考虑各种内容样式。看来,如果我要采用 XSL 路线来格式化我的内容,我将留下一个巨大的模板 CF,试图解释每种可能性。我的意思是,我可能希望我的内容采用以下方式格式化,但不限于:
等等......
Thanks for the reply, Tomalak.
I'm currently using something like you suggested, however, it seems I'm going to have a lot of display cases. Meaning that my XSL will have to account for a wide variety of content styles. It seems that if I were to go the XSL route to format my content, I'd be left with a big CF of template trying to account for every possibility. I mean, I could want my content to be formated in the following ways, but not limited to:
And so on...