- To: 'Jeni Tennison' <jeni@j...>
- Subject: RE: XML Schema Validation Problem
- From: Jason Brown <Jason@i...>
- Date: Thu, 9 Jan 2003 11:26:10 -0000
- Cc: "XML-DEV (E-mail)" <xml-dev@l...>
Title: RE: XML Schema Validation Problem
Hi Jeni,
Thank you very much, That is now working fine. I had the XPath property set but didn't know about the namespaces property.
Best regards
Jason
-----Original Message-----
From: Jeni Tennison [mailto:jeni@j...]
Sent: 09 January 2003 11:06
To: Jason Brown
Cc: XML-DEV (E-mail)
Subject: Re: XML Schema Validation Problem
Hi Jason,
> I have a Schema that has 2 namespaces. This is referenced by an XML
> document. I can successfully parse the XML against the schema,
> however I cannot then assign any data to an Object using the
> SelectSingleNode method of a FreeThreadedDOMDocument40. According to
> the object browser this should return an IXMLDOMNode, the result I
> get is the object is still nothing.
You don't show the code that you're using, but my guess would be that
when you use selectSingleNode(), you're not including a namespace
prefix on the element name. Try using the following code:
// Use XPath rather than XSL Patterns to select your nodes
yourDOM.setProperty("SelectionLanguage", "XPath");
// Declare the namespace you want to use with a prefix
yourDOM.setProperty("SelectionNamespaces", "xmlns:xyz='xyz'");
// Use the prefix when you refer to the element you want to select
node = yourDOM.selectSingleNode("/xyz:Environment");
When you use XPath, if you specify an element name without a prefix as
in "/Environment" then you will only select elements with that local
name in *no namespace*. If you want to select elements that are in a
namespace (as your <Environment> element is) then you need to declare
that namespace with a prefix and use that prefix to refer to the
element.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
|