How can I manage microdata with xslt?

人盡茶涼 提交于 2019-12-04 00:42:09

问题


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.


回答1:


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!




回答2:


<xsl:text disable-output-escaping="yes"><![CDATA[<div itemscope>]]></xsl:text>


来源:https://stackoverflow.com/questions/6453405/how-can-i-manage-microdata-with-xslt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!