如何使用 xslt 管理微数据? [英] How can I manage microdata with xslt?

查看:17
本文介绍了如何使用 xslt 管理微数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加像

这样的标签

在我的 xslt 转换中,但出现错误.(预期标记为 '=')

我正在使用 C# .net 4.0 xslt 1.0.

解决方案

XSLT 针对生成 XML 输出进行了优化.一般来说,HTML5 不是 XML.语法

显然不是 XML,因此不能使用 xsl:attribute 生成.这是因为 XML 不支持空值属性.这是个坏消息.

好消息:有两种方法可以编写与

相同的东西,它们是有效的 HTML5 有效的 XML:

<div itemscope="itemscope">

所以选择你最喜欢的并生成它!

I'm trying to add a tag like

<div itemscope>

in my xslt transformation but I get an error.(The expected token is '=')

I'm working in C# .net 4.0 xslt 1.0.

解决方案

XSLT is optimized for generating XML output. HTML5 is, in general, not XML. The syntax

<div itemscope>

is clearly not XML and therefore can't be generated using xsl:attribute. This is because XML doesn't support empty-valued attributes. That's the bad news.

The good news: There are two ways of writing the same thing as <div itemscope> that are valid HTML5 and valid XML:

<div itemscope="">
<div itemscope="itemscope">

So pick your favorite and generate that!

这篇关于如何使用 xslt 管理微数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆