473,734 Members | 2,647 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i specify default XML namespace when it does not declared in the xml document

How can i specify default XML namespace when it does not declared in
the xml document
I need it for validation against xml schema

@@@I have a procedure
Sub ValidateXMLDocu ment(ByRef XMLDocument As Xml.XmlDocument , ByVal
SchemaPath as string)

If XMLDocument.Doc umentElement.Na mespaceURI = String.Empty Then
'@@@ calculating target namspace of the schema
Dim schemaDoc as XmlDocument = new XMLDocument
schemaDoc.load( SchemaPath)
Dim targetNamespace as string =
schemaDoc.selec tSingleNode("@t argetNamespace" ).value

'@@@ Here i need help of experts!
'@@@ how can i provide targetNamespace in to the XMLDocument to
specify that
'@@@this document belongs to this namespace?
End If

'@@@ here goes standart opearion of the validation xmldocument against
xml schema
End Sub
P.S. Creating attribute with name "xmlns" does't work
Nov 12 '05 #1
1 2968
Izvra wrote:
How can i specify default XML namespace when it does not declared in
the xml document
I need it for validation against xml schema

@@@I have a procedure
Sub ValidateXMLDocu ment(ByRef XMLDocument As Xml.XmlDocument , ByVal
SchemaPath as string)

If XMLDocument.Doc umentElement.Na mespaceURI = String.Empty Then
'@@@ calculating target namspace of the schema
Dim schemaDoc as XmlDocument = new XMLDocument
schemaDoc.load( SchemaPath)
Dim targetNamespace as string =
schemaDoc.selec tSingleNode("@t argetNamespace" ).value

'@@@ Here i need help of experts!
'@@@ how can i provide targetNamespace in to the XMLDocument to
specify that
'@@@this document belongs to this namespace?


That's kinda weird. You wanna adjust XML instance according to schema?
Generally you cannot change namespace of all nodes in the document
in-memory, because namespace is integral part of a node. The simplest
way I see is to recreate document in appropriate way (e.g. 10-lines XSLT
stylesheet can move all nonamespace elements to a namespace).
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
Nov 12 '05 #2

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

Similar topics

1
6851
by: Seong-Tae Jeong | last post by:
for example, xml document is below, It has a default namespace "xmlns='qwer://test'". string xmlText = "<test xmlns='http://test'><clear/><clear/></test>"; I would like to select node list "clear" with XPath Expression. XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml( xmlText );
11
4323
by: EAI | last post by:
Hi All, I have a XML of the following form <?xml version="1.0"?> <xxxx xmlns="http://xxx.xxx.com"> .... </xxxx> When I try to read xml using SelectSingleNode, I am getting exception
2
1601
by: Nicolas | last post by:
Hi everybody... In Xerces 2.7.0 it is explicitly stated that, no matter how one removes an attribute (attList->removeNamedItem, attList->removeNamedItemNS, domElement->removeAttributeNode, domElement->removeAttribute, domElement->removeAttributeNS), if that attribute has a default value it is immediately replaced. However I cannot obtain that behaviour...
1
1845
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST> xml file 2
12
8560
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
37
4195
by: Jan Wagner | last post by:
Hi, can't figure this one out, what's the CSS way to specify the language? In HTML it would be simply an lang="xx" attribute, or XHTML xml:lang="xx", but, how about in CSS? This would be required for a screen reader (text to speech) for accessibility, to help the reader software use the correct presentation method (e.g. correct language module).
4
7719
by: Samuel R. Neff | last post by:
I'm writing an xslt in vs.net 2003 and in order to get intellisense on the html content I added the default namespace declaration xmlns="http://schemas.microsoft.com/intellisense/ie5". However, even though I also have exclude-result-prefixes="#default" declared the default namespace is still outputted on the resulting document. <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0"...
2
3045
by: Mark | last post by:
Hi... I've been trying the .Validate() method on the XmlDocument to validate some xml against a schema, but one thing I noted was that unless the document explicitly declares the schema as a default namespace, Validate() just lets it slide through as a success. Is there a way to Validate() either a) mandating against a particular schema, or at the very least b) supplying a default namespace to be used even when not explicitly declared?
1
2232
by: Arndt Jonasson | last post by:
The definition of XPath 1.0 says "A QName in the node test is expanded into an expanded-name using the namespace declarations from the expression context. This is the same way expansion is done for element type names in start and end-tags except that the default namespace declared with xmlns is not used: if the QName does not have a prefix, then the namespace URI is null (this is the same way attribute names are expanded). It is an error...
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9310
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4550
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.