473,324 Members | 2,193 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,324 software developers and data experts.

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 ValidateXMLDocument(ByRef XMLDocument As Xml.XmlDocument, ByVal
SchemaPath as string)

If XMLDocument.DocumentElement.NamespaceURI = String.Empty Then
'@@@ calculating target namspace of the schema
Dim schemaDoc as XmlDocument = new XMLDocument
schemaDoc.load(SchemaPath)
Dim targetNamespace as string =
schemaDoc.selectSingleNode("@targetNamespace").val ue

'@@@ 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 2946
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 ValidateXMLDocument(ByRef XMLDocument As Xml.XmlDocument, ByVal
SchemaPath as string)

If XMLDocument.DocumentElement.NamespaceURI = String.Empty Then
'@@@ calculating target namspace of the schema
Dim schemaDoc as XmlDocument = new XMLDocument
schemaDoc.load(SchemaPath)
Dim targetNamespace as string =
schemaDoc.selectSingleNode("@targetNamespace").val ue

'@@@ 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
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...
11
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
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,...
1
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
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
37
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...
4
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,...
2
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...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.