473,395 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Extracting the xmlns:v attribute out of an HTML element in IE?

I'm attempting to write a quick piece of Javascript code that will
validate if the end user of the javascript has the necessary VML
attributes set in their HTML. The problem in IE is that "xmlns:v"
does not appear in their attributes property or the
getAttribute('xmlns:v') calls. The real kicker is that the 'xmlns'
attribute does return something.

The HTML Snippet would look like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-
microsoft-com:vml" anthony="abc">
<head>

------------------------

var htmlElement = window.top.document.getElementsByTagName("html")[0];

//Returns "http://www.w3.org/1999/xhtml" Expected "http://www.w3.org/
1999/xhtml"
var validAttr = htmlElement.getAttribute('xmlns');

//Returns "" Expected "urn:schemas-microsoft-com:vml"
var badAttr = htmlElement.getAttribute('xmlns:v');

------------

Does anyone have any suggestions for how to either get this value, or
perhaps another way to validate that the VML ns has been installed?

Feb 1 '07 #1
2 2534
VK
On Feb 1, 8:11 pm, "aglaforge" <aglafo...@gmail.comwrote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-
microsoft-com:vml" anthony="abc">
<head>
a side note: what is anthony="abc" ? <htmltag is not a place for
copyrigths, memos or quick notes ;-) Except namespaces and maybe lang
anything else out, no matter what different specs may say.

Now:
by Mycrosoft HTML has default namespace and it is called "HTML"; also
IE knows nothing about XHTML.
This way ...html xmlns="http://www.w3.org/1999/xhtml"... is simply
ignored by error correction mechanics so <htmland all other tags
without namespace prefix will stay in the default "HTML" namespace,
that will be happily reported by anyone of them if you ask to, say:
alert( document.getElementsByTagName('head')[0].scopeName )

....xmlns:v="urn:schemas-microsoft-com:vml"...
adds new "v" namespace, so any element prefixed by v: will be counted
as appertaining to this namespace; but obviously it doesn't affect
<htmlelement itself - it remains in the default namespace - thus
there is no use to harass it :-). All registered namespaces are stored
in document.namespaces collection, all unknown namespaces reported as
null. This way the check is as easy as:
if (document.namespaces['v'] == null) {
// needed xmlns is missing
}

P.S. Just in case a reminder: in Microsoft model xmlns doesn't impose
any predefined formatting or behavior on involved elements. It only
instructs the parser to exclude properly prefixed elements from the
standard "skip unknown tag" error correction mechanics, as it would be
with some <aaa>foobar</aaa>.
On the second necessary step you have to add implementation or
behavior to this namespace.

P.P.S. Funny enough this junky pseudo-xhtml combo above - if served as
text/html - is fully compatible with both W3C and Microsoft models
plus makes Validator all green of hapiness. I'm using this trick too
occasionally when I need to satisfy standards-shifted clients. With
all fixes hidden into conditional CSS: " see it works on IE, see it
works on Gecko, see it validates on*strict* **XHTML** " Works like a
charm :-)
Feb 1 '07 #2
On Feb 1, 12:28 pm, "VK" <schools_r...@yahoo.comwrote:
On Feb 1, 8:11 pm, "aglaforge" <aglafo...@gmail.comwrote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-
microsoft-com:vml" anthony="abc">
<head>

a side note: what is anthony="abc" ? <htmltag is not a place for
copyrigths, memos or quick notes ;-) Except namespaces and maybe lang
anything else out, no matter what different specs may say.

Now:
by Mycrosoft HTML has default namespace and it is called "HTML"; also
IE knows nothing about XHTML.
This way ...html xmlns="http://www.w3.org/1999/xhtml"... is simply
ignored by error correction mechanics so <htmland all other tags
without namespace prefix will stay in the default "HTML" namespace,
that will be happily reported by anyone of them if you ask to, say:
alert( document.getElementsByTagName('head')[0].scopeName )

...xmlns:v="urn:schemas-microsoft-com:vml"...
adds new "v" namespace, so any element prefixed by v: will be counted
as appertaining to this namespace; but obviously it doesn't affect
<htmlelement itself - it remains in the default namespace - thus
there is no use to harass it :-). All registered namespaces are stored
in document.namespaces collection, all unknown namespaces reported as
null. This way the check is as easy as:
if (document.namespaces['v'] == null) {
// needed xmlns is missing
}

P.S. Just in case a reminder: in Microsoft model xmlns doesn't impose
any predefined formatting or behavior on involved elements. It only
instructs the parser to exclude properly prefixed elements from the
standard "skip unknown tag" error correction mechanics, as it would be
with some <aaa>foobar</aaa>.
On the second necessary step you have to add implementation or
behavior to this namespace.

P.P.S. Funny enough this junky pseudo-xhtml combo above - if served as
text/html - is fully compatible with both W3C and Microsoft models
plus makes Validator all green of hapiness. I'm using this trick too
occasionally when I need to satisfy standards-shifted clients. With
all fixes hidden into conditional CSS: " see it works on IE, see it
works on Gecko, see it validates on*strict* **XHTML** " Works like a
charm :-)
That's help alot, thank you very much!

Feb 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Saqib Ali | last post by:
Hello All, I am using Norman Walsh's XSLTs to transform some DocBook XML content to HTML. However I noticed that Norman Walsh's DocBook XSLT includes the following tag in the transformed...
3
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
4
by: Porthos | last post by:
Hi All, I've been working on mining data from a schema file (all attribute data so far) and have come to the point where I need to get information that is contained in tags. For instance,...
4
by: David S. Alexander | last post by:
I am trying to transform XML to XML using an XSLT in C#, but the root node of my XML is not being matched by the XSLT if it has an xmlns attribute. Am I handling my namespaces incorrectly? My C#...
7
by: Simon Hart | last post by:
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a...
3
by: dhurwitz | last post by:
I am trying to create an XML spreadsheet for use with Excel. I first saved a simple spreadsheet as an XML file, and now I am trying to recreate that file in code, using .NET 2.0. The beginning of...
0
by: jts2077 | last post by:
I am trying to create a large nested XML object using E4X methods. The problem is the, the XML I am trying to create can only have xmlns set at the top 2 element levels. Such as: <store ...
1
by: C.W.Holeman II | last post by:
I have an xmlns attribute that produces an XHTML validation error and I do not understand why it is considered an error.The file displays as expected on Firefox and IE7. ...
4
by: BorisBoshond | last post by:
Hi all, Hope someone is able and willing to help me with following problem. I received a xsd file from another company, our company i supposed to return xml based on that xsd. Problem is that I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.