?
Solved

Removing XHTML namespace

Posted on 2003-03-03
9
Medium Priority
?
650 Views
Last Modified: 2013-12-16
I have the following XHTML:

 <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/1999/xhtml" w2x:generator-version="1.0" xmlns:w2x="urn:schemas-docsoft-com:word-to-xml:extensions">
  <head>
  <title />
  <title>Corporate Profile</title>
  </head>
  <body lang="EN-US" link="blue" vlink="purple" w2x:class="w2x_style_10000">
...
</body>
</html>

That is generated from software we have that converts Word to XML. I have written a custom XSLT to add the XML processing instruction, but I cannot find a way of removing the XHTML namespace. Here is my XSLT:

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:h="http://www.w3.org/1999/xhtml"
     exclude-result-prefixes="h">

     <xsl:output method="xml" encoding="iso-8859-1" indent="yes"
               omit-xml-declaration="no" />

<xsl:template match="h:html">
<doc>
<xsl:copy-of select="*" />
</doc>
</xsl:template>

</xsl:stylesheet>

The output I get is:

  <?xml version="1.0" encoding="utf-8" ?>
  <doc>
  <head xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/1999/xhtml">
  <title />
  <title>Corporate Profile</title>
  </head>
  <body lang="EN-US" link="blue" vlink="purple" xp_0:class="w2x_style_10000" xmlns:xp_0="urn:schemas-docsoft-com:word-to-xml:extensions" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/1999/xhtml">

I need to get rid of the xmlns="http://www.w3.org/1999/xhtml" namespace. Please help.

XML Dude
0
Comment
Question by:xmldudeus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 27

Expert Comment

by:BigRat
ID: 8064021
The problem is the xsl:copy-of instruction. Try adding the attribute copy-namespaces = "no". You may find however that namespace fixup causes them to reappear. If this is the case you are going to have to match every element in the source tree and create a new element in the output tree.
0
 
LVL 4

Expert Comment

by:chabaud
ID: 8064037
I have not test it, but you could try to exclude the default namespace adding #default in the exclude list like this:

exclude-result-prefixes="h #default"

EC.
0
 

Author Comment

by:xmldudeus
ID: 8064334
Neither of these worked. I really didn't want to match each element, but I may have to. Any other ideas?
0
WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

 
LVL 27

Expert Comment

by:BigRat
ID: 8070852
The problem is that the XSL namespace fixup is very strict about setting such things. The "exclude-result" operation only supresses effectively unused namespace declarations on output. Other than matching each occurence, I see no way of getting rid of it.

One minor point, you specify an output encoding of iso-8859-1 but you have got utf-8. Is that correct?
0
 

Author Comment

by:xmldudeus
ID: 8072033
Yeah, that is correct about the utf-8. Do you know why?
0
 
LVL 27

Expert Comment

by:BigRat
ID: 8072112
No, you clearly specifiy iso. Are you using MSXML or something else? Do you get the indenting?

TZry also to get rid of the other redundant namespaces (well I assume they are redundant) like v,o,w and st1.

Incidentally, the output looks suspiciously like HTML so why is the output method set to xml?
0
 

Author Comment

by:xmldudeus
ID: 8072201
This is output from some very cool software we use called "W2XML" - we use it to convert our Word docs to XML. It has some other XSLTs to convert the output to other types of XML, (such as Docbook), but I was trying to keep the standard output and just put an XML processing instruction at the top (the standard output is XHTML from this software) - trying to create my own XSLT to use with the software.

There is indentation, but I am not sure it is a result of MSXML or not. MSXML is not a requirement of the software, but it does require the .NET Framework, which I think inherently uses MSXML.

0
 
LVL 27

Accepted Solution

by:
BigRat earned 400 total points
ID: 8072320
DocSoft! And the transform (Adds XML processing instruction and removes HTML wrapper from standard output) from xmldudeus. And of course uses the MS XML object.

They actually say on their web site that namespaces should be removed manually, however I think you are going to have to match every "html" node and make a new one. At least you can upload the transform to the DocSoft web site for everybody else!
0
 

Author Comment

by:xmldudeus
ID: 8072349
Yeah - I will upload it when I finish it. Thanks for your help, BigRat!
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question