Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Removing XHTML namespace

Posted on 2003-03-03
9
Medium Priority
?
664 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Geo-targeting is the practice of distributing content based on a person’s location, as best as you can determine it. Let’s look at some ways you could successfully use this tactic. The following tips and case studies could lead to meaningful results.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

571 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