【问题标题】:How to remove namespace from a an element of html2 transform created output如何从 html2 转换创建的输出的元素中删除命名空间
【发布时间】:2017-08-03 11:42:48
【问题描述】:

是否可以使用名为 org.dita4publishers.html2 的插件从 html2 转换输出生成的输出中删除命名空间

我已经生成了从 dita 到 html2 的输出,我得到了 fig

我正在从 html2 转换获取输出

<div xmlns="http://www.w3.org/1999/xhtml" class="fignone" id="call1">
<div class="figbody">
<img xmlns="" src="images/imag1.png"></img>
</div>
<span class="figcap"><span class="enumeration fig-enumeration">Figure 1. </span>Nursing image</span></div>

但我想像这样排除命名空间

<div class="fignone" id="call1">
<div class="figbody">
<img xmlns="" src="images/imag1.png"></img>
</div>
<span class="figcap"><span class="enumeration fig-enumeration">Figure 1. </span>Nursing image</span></div>

我正在使用模板生成 css 链接

<xsl:template match="*" mode="chapterHead">
   <head><xsl:value-of select="$newline"/>
     <!-- initial meta information -->
   <link rel="stylesheet" type="text/css" href="css/care.css"/><xsl:value-of select="$newline"/>
   </head>
   <xsl:value-of select="$newline"/>
 </xsl:template>

但是像这样生成输出

<head>
<link rel="stylesheet" type="text/css" href="care.css"></link>
</head>

它忽略了/之前的文字,也忽略了/

我想输出为

<head>
<link rel="stylesheet" type="text/css" href="css/care.css"></link>
</head>

请就这些问题向我提出建议。

注意:我也使用了 exclude-result-prefixes="#all"。但它不起作用。

提前致谢

【问题讨论】:

    标签: xml xslt dita-ot


    【解决方案1】:

    您对问题的描述不正确。就 XDM 数据模型而言,您不想从输出中“删除命名空间”,而是希望输出中的每个元素都位于与其当前所在的不同的命名空间中。(具体来说,您希望它不在命名空间中)。这会影响创建元素的每条指令。因此,实现这一点的最简单方法可能是对当前输出进行后处理,使用模板规则更改命名空间

    <xsl:template match="*">
      <xsl:element name="{local-name()}">
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates/>
      </xsl:element>
    </xsl:template>
    

    【讨论】:

    • 嗨@Michael Kay 我正在从名为org.dita4publishers.html2 的dita ot 插件生成html2 输出,在输出中我正在为dita 文件中的fig 标记获取索引和主题文件,它生成div 标记在 'xmlns="w3.org/1999/xhtml"'' 里面,如果我尝试过你的代码,它不会在输出中应用任何更改
    猜你喜欢
    • 1970-01-01
    • 2011-01-06
    • 1970-01-01
    • 2020-03-24
    • 2012-03-10
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 2019-10-01
    相关资源
    最近更新 更多