User515
User515

Reputation: 186

How to remove namespace from a an element of html2 transform created output

Is it possible to remove namespace from an output which is generated by html2 transform output using plugin named org.dita4publishers.html2

I have generated the output from dita to html2 out put i am getting for fig

I am getting output from html2 transform

<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>

But i want to exclude namespace as like this

<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>

and i am generating css links using template

<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>

but generating output as like this

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

its neglecting the text before / and also neglecting the /

I want output as

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

Please suggest me on these issues.

Note: I had used exclude-result-prefixes="#all" also. But its not working.

Thanks in Advance

Upvotes: 0

Views: 50

Answers (1)

Michael Kay
Michael Kay

Reputation: 163342

You've described the problem incorrectly. In terms of the XDM data model, you don't want to "remove a namespace" from the output, you want every element in the output to be in a different namespace from the one it is currently in. (Specifically, you want it to be in no namespace). That affects every instruction that creates an element. So the easiest way to achieve this is probably by a post-processing pass on the current output, changing the namespace using the template rule

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

Upvotes: 0

Related Questions