473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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('x mlns: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:sc hemas-
microsoft-com:vml" anthony="abc">
<head>

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

var htmlElement = window.top.docu ment.getElement sByTagName("htm l")[0];

//Returns "http://www.w3.org/1999/xhtml" Expected "http://www.w3.org/
1999/xhtml"
var validAttr = htmlElement.get Attribute('xmln s');

//Returns "" Expected "urn:schema s-microsoft-com:vml"
var badAttr = htmlElement.get Attribute('xmln s: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 2553
VK
On Feb 1, 8:11 pm, "aglaforge" <aglafo...@gmai l.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:sc hemas-
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.getEle mentsByTagName( 'head')[0].scopeName )

....xmlns:v="ur n: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.namesp aces collection, all unknown namespaces reported as
null. This way the check is as easy as:
if (document.names paces['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...@y ahoo.comwrote:
On Feb 1, 8:11 pm, "aglaforge" <aglafo...@gmai l.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:sc hemas-
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.getEle mentsByTagName( '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.namesp aces collection, all unknown namespaces reported as
null. This way the check is as easy as:
if (document.names paces['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
2163
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 document: <meta xmlns="http://www.w3.org/1999/xhtml" ......
3
10030
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" xmlns:ns1="abc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" media-type="text/xml" standalone="yes" version="1.0"/>...
4
1584
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, <tag>My Data Here</tag>. I've tried using the <xsl:value-of select="tag"/> element, but it does not appear to work in schema files. Is this correct? Is...
4
3584
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# code is, // Create an XSLT transform object XslTransform xslTransform = new XslTransform(); // Load the stylesheet
7
2966
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 xmlns present is because the Xml I am passing to CRM is a node from a bigger file that does require a xmlns and using the DOM ..OuterXml seems to...
3
11172
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 the XML file should look like the following: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook...
0
2781
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 xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> <product sku="10050-1653" xmlns="http://www.store.com/xml/1.1.0.0/impex/catalog"> ...
1
3826
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. http://emle.sourceforge.net/emle020100/lab/ng20070625_emle_lab_001-e.xml.html <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus...
4
4802
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 don't really understand how these namespace work in xml. (I am however aware of what problems namespaces solve) I'm not even sure if the provided...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.