473,505 Members | 14,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Validation - Unable to work with namespace prefixes

I am currently developing an xbrl validation software that takes an xml
instance file and a lot of schemas(xsd files) and validates it against the
xsd files. I am using Visual basic in visual studio 2005. I have managed to
cycle through the xml file , validate most of the variables, however, i have
some problems with the namespaces of some attributes.

For example, in my xml instance file, it says:

<xbrldi:typedMember dimension="d-ty:NationalMarketDimension">
<d-ty:NationalMarket>base metals</d-ty:NationalMarket>
</xbrldi:typedMember>

In this case, the attribute name is "dimension" and
the attribute value is "d-ty:NationalMarketDimension".
The problem is that "dimension" variable is in one namespace, and
"d-ty:NationalMarketDimension" is in another namespace. i execute the
following code:

validator.ValidateAttribute(reader.name, reader.NamespaceURI,
reader.valuevalue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMarketDimension" should be validated using
the d-ty namespace, which is another x-sd file.
The error i get is :
Error Message:The 'dimension' attribute is invalid - The value
'd-ty:NationalMarketDimension' is invalid according to its datatype
'http://www.w3.org/2001/XMLSchema:QName' - 'd-ty' is an undeclared namespace.

Can anyone help ?
Thank you

Oct 2 '06 #1
3 2920


George wrote:
<xbrldi:typedMember dimension="d-ty:NationalMarketDimension">
<d-ty:NationalMarket>base metals</d-ty:NationalMarket>
</xbrldi:typedMember>
The error i get is :
Error Message:The 'dimension' attribute is invalid - The value
'd-ty:NationalMarketDimension' is invalid according to its datatype
'http://www.w3.org/2001/XMLSchema:QName' - 'd-ty' is an undeclared namespace.
Is there a namespace declaration alike
xmlns:d-ty="someURN"
in scope? The snippet does not show any.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 2 '06 #2
The problem you are seeing is not for validation of the attribute's
namespace. it is becuase you do not have the prefix d-ty mapped to a
namespace-uri. When you construct the XmlSchemaValidator [1], you need to
pass in a Namespace Resolver which maps it to a namespace.

[1]
http://msdn2.microsoft.com/en-us/lib...validator.aspx

"George" <Ge****@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
>I am currently developing an xbrl validation software that takes an xml
instance file and a lot of schemas(xsd files) and validates it against
the
xsd files. I am using Visual basic in visual studio 2005. I have managed
to
cycle through the xml file , validate most of the variables, however, i
have
some problems with the namespaces of some attributes.

For example, in my xml instance file, it says:

<xbrldi:typedMember dimension="d-ty:NationalMarketDimension">
<d-ty:NationalMarket>base metals</d-ty:NationalMarket>
</xbrldi:typedMember>

In this case, the attribute name is "dimension" and
the attribute value is "d-ty:NationalMarketDimension".
The problem is that "dimension" variable is in one namespace, and
"d-ty:NationalMarketDimension" is in another namespace. i execute the
following code:

validator.ValidateAttribute(reader.name, reader.NamespaceURI,
reader.valuevalue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMarketDimension" should be validated
using
the d-ty namespace, which is another x-sd file.
The error i get is :
Error Message:The 'dimension' attribute is invalid - The value
'd-ty:NationalMarketDimension' is invalid according to its datatype
'http://www.w3.org/2001/XMLSchema:QName' - 'd-ty' is an undeclared
namespace.

Can anyone help ?
Thank you

Oct 2 '06 #3
Thank you for your reply,

at the top of the xml-instance document i have this code

<xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance"
xmlns:link="http://www.xbrl.org/2003/linkbase"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:t-me="http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/t-me-2006-07-01"
xmlns:d-hh="http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/d-hh-2006-07-01"
xmlns:d-mr="http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/d-mr-2006-07-01"
.... and it goes on for some more declarations. So the "d-mr" missing
namespace is declared. And the "d-ty" in the same sense.

I am also using in my code a manager , kind of like a resolver i think,
which resolves the prefixes of the namespaces. The code is below:

Dim manager As XmlNamespaceManager = New XmlNamespaceManager(reader.NameTable)
manager.AddNamespace("d-mr",
"http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/d-mr-2006-07-01")
manager.AddNamespace("d-ty",
"http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/d-mr-2006-07-01")

I then pass the manager to the validator :
'sc is the schemaset
Dim validator As XmlSchemaValidator = New
XmlSchemaValidator(reader.NameTable, sc, manager, settings.ValidationFlags)

The problem is now that even though that there is not a
d-mr:NotaValidVariable in the d-mr namespace, the validator resolves the
prefix, and outputs a valid variable. This fails in all the variables that
use a prefix . Variables that do not use a prefix, return an error message ,
either that are missing ot they have type mismatch, which is the desired
result.

Thank you
George

"Zafar Abbas" wrote:
The problem you are seeing is not for validation of the attribute's
namespace. it is becuase you do not have the prefix d-ty mapped to a
namespace-uri. When you construct the XmlSchemaValidator [1], you need to
pass in a Namespace Resolver which maps it to a namespace.

[1]
http://msdn2.microsoft.com/en-us/lib...validator.aspx

"George" <Ge****@discussions.microsoft.comwrote in message
news:9F**********************************@microsof t.com...
I am currently developing an xbrl validation software that takes an xml
instance file and a lot of schemas(xsd files) and validates it against
the
xsd files. I am using Visual basic in visual studio 2005. I have managed
to
cycle through the xml file , validate most of the variables, however, i
have
some problems with the namespaces of some attributes.

For example, in my xml instance file, it says:

<xbrldi:typedMember dimension="d-ty:NationalMarketDimension">
<d-ty:NationalMarket>base metals</d-ty:NationalMarket>
</xbrldi:typedMember>

In this case, the attribute name is "dimension" and
the attribute value is "d-ty:NationalMarketDimension".
The problem is that "dimension" variable is in one namespace, and
"d-ty:NationalMarketDimension" is in another namespace. i execute the
following code:

validator.ValidateAttribute(reader.name, reader.NamespaceURI,
reader.valuevalue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMarketDimension" should be validated
using
the d-ty namespace, which is another x-sd file.
The error i get is :
Error Message:The 'dimension' attribute is invalid - The value
'd-ty:NationalMarketDimension' is invalid according to its datatype
'http://www.w3.org/2001/XMLSchema:QName' - 'd-ty' is an undeclared
namespace.

Can anyone help ?
Thank you



Oct 3 '06 #4

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

Similar topics

0
1382
by: Andy Dingley | last post by:
I'm writing XSLT to transform fntg-schema (our own project's document schema) into PartnerML, a HTML-like XML dialect used for mobile phones. I'm using XMLSPy 4.4 to do this. The schema for...
4
1480
by: ian.rutgers | last post by:
In validating http://www.otima.ca/XML/auto.xml (auto.xsd) I get the following error: "Attribute 'make' should be qualified" If you look at my schema i do havit it qualified, so I don't...
0
1233
by: S ML | last post by:
Hello, I use the Xerces XS* classes to parse and get the definition of an XML schema. I don't seem to find a way to get the namespace prefixes using this framework and I read somewhere that the...
19
16072
by: David Thielen | last post by:
Hi; If there are no namespaces this works fine for me. But if the xml has namespaces, then I get either no node back or an exception. Here is the sample xml: <root xmlns="http://www.test.org"...
1
2415
by: Stephen Adam | last post by:
Hi there, I have written a custom validation control which checks to see of an input field is not empty and contains only numeric data. I was using a regular expression validation control but...
2
3464
by: steve | last post by:
Can someone point me to some information on namespace best practices? Questions I have are as follows: 1) Should I use .NET namespaces or URL, URI and URN's? Ie mycompany.mydivision.myapp vs...
6
2715
by: lists | last post by:
Hi all, I am trying to validate an XML file against an XSD schema file within a ..NET C++ program, but the validation doesn't seem to be occuring. My code is listed below. The validation...
3
6873
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post by:
Hi, I am new to using the MSXML functions in C++. I found this on MSDN as an example of what I wanted to do, http://msdn2.microsoft.com/en-us/library/ms765465.aspx. I have tried a number of...
6
2242
by: Juha Nieminen | last post by:
Whenever one sees example C++ code basically anywhere, be it in a book, in a tutorial in the internet, in an online forum or whatever, I would estimate that at least in 99% of cases one sees the...
0
7216
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
7098
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...
1
5028
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...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
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 ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
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...

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.