使用XSLT从xhtml文件中获取所有元素
我有一个 xhtml 文件,我正在尝试对其进行转换,以便:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>yada</title>
<meta.....>
</head>
<body>
<p>Something</p>
<p>awesome</p>
</body>
</html>
成为 a
<title>yada</title>
<meta.....>
<p>Something</p>
<p>awesome</p>
我要处理的关键问题是 和
标签已从文档中删除。我不想通过 sed 或 awk 运行它来删除它们。
我尝试过的所有内容要么全部包含在 html 中,要么全部转换为纯文本。
问题背景:我有一个用 multimarkdown 编写的博客的备份,我希望将它们放入不同的格式,但我需要首先解决这个问题。
注意:我从身份模板开始。
I have an xhtml file that I'm attempting to transform such that:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>yada</title>
<meta.....>
</head>
<body>
<p>Something</p>
<p>awesome</p>
</body>
</html>
becomes a
<title>yada</title>
<meta.....>
<p>Something</p>
<p>awesome</p>
The key thing that I'm getting at is that the <head>
and <body>
tags are removed from the document. I don't want to run this through sed or awk to remove them.
Everything that I've tried either has the whole thing in html or converts it all into pure text.
Background on problem: I've got a backup of my blog written in multimarkdown, I'm hoping to put them into different format but I need to get over this issue first.
Note: I started off with the identity template.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的东西? (请耐心等待,我已经很久没有积极使用 XSL 了)
something like this? (bear with me, its been ages since I've done XSL actively)
听起来您想要对
html
和body
下面的所有内容进行身份转换:Sounds like you want the identity transform for everything below
html
andbody
:您确定这不是常见的名称空间问题吗?输入是否真的像您向我们展示的那样,或者您是否遗漏了名称空间,因为您没有意识到它们产生了所有差异?
Are you sure this isn't the usual namespace problem? Does the input really look like you showed us, or did you leave out the namespaces because you didn't realise they made all the difference?