简体   繁体   中英

Output is not displaying in HTML format after transforming the xml result using xslt when the attribute name contains special character

My xml has just 1 value as name =RDXXX-LOWER_DECK, value=10 mm. When this is transformed using xslt I get output correctly as below:

 <table>
 <tr valign="top">
 <td width="200">RDXXX-LOWER_DECK</td>
 <td width="200">10.000000000000 mm</td>
 </tr>
 </table>

But when I replace RDXXX-LOWER_DECK as RDXXX||LOWER_DECK (hyphen is replaced with double pipe) I don't get the output. Empty value is printed and name is printed as "Attribute".

 <table>
 <tr valign="top">
 <td width="200">Attribute</td>
 <td width="200"></td>
 </tr>
 </table>

KIndly let me know how to retain || in the output.

My code is as below:

 <xsl:template match="wc:INSTANCE">
 <table border="1">
 <xsl:for-each select="*">
  <xsl:if test='(local-name(.)!="obid") and (local-name(.)!="CLASS")'>
    <tr valign="top">
      <td width="200">
        <xsl:value-of select="local-name(.)"/>
      </td>
      <td width="200"><xsl:value-of select='.'/></td>
    </tr>
  </xsl:if>
</xsl:for-each>
 </table>
 </xsl:template>

My xml has just 1 value as name =RDXXX-LOWER_DECK, value=10 mm.
But when I replace RDXXX-LOWER_DECK as RDXXX||LOWER_DECK (hyphen is replaced with double pipe)...

If by that you mean that you have an XML like this:

<RDXXX-LOWER_DECK>10mm</RDXXX-LOWER_DECK>

and you changed it to look like this:

<RDXXX||LOWER_DECK>10mm</RDXXX||LOWER_DECK>

then you no longer have a well-formed XML document. The | character is not allowed in an element name .

... I don't get the output. Empty value is printed and name is printed as "Attribute".

That is strange, because you should have been getting an error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM