473,608 Members | 1,809 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:typedMe mber dimension="d-ty:NationalMark etDimension">
<d-ty:NationalMark et>base metals</d-ty:NationalMark et>
</xbrldi:typedMem ber>

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

validator.Valid ateAttribute(re ader.name, reader.Namespac eURI,
reader.valueval ue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMark etDimension" 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:NationalMark etDimension' 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 2932


George wrote:
<xbrldi:typedMe mber dimension="d-ty:NationalMark etDimension">
<d-ty:NationalMark et>base metals</d-ty:NationalMark et>
</xbrldi:typedMem ber>
The error i get is :
Error Message:The 'dimension' attribute is invalid - The value
'd-ty:NationalMark etDimension' 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 XmlSchemaValida tor [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****@discuss ions.microsoft. comwrote in message
news:9F******** *************** ***********@mic rosoft.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:typedMe mber dimension="d-ty:NationalMark etDimension">
<d-ty:NationalMark et>base metals</d-ty:NationalMark et>
</xbrldi:typedMem ber>

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

validator.Valid ateAttribute(re ader.name, reader.Namespac eURI,
reader.valueval ue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMark etDimension" 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:NationalMark etDimension' 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="ht tp://www.xbrl.org/2003/instance"
xmlns:link="htt p://www.xbrl.org/2003/linkbase"
xmlns:xlink="ht tp://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 XmlNamespaceMan ager = New XmlNamespaceMan ager(reader.Nam eTable)
manager.AddName space("d-mr",
"http://www.c-ebs.org/eu/fr/esrs/corep/2006-07-01/d-mr-2006-07-01")
manager.AddName space("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 XmlSchemaValida tor = New
XmlSchemaValida tor(reader.Name Table, sc, manager, settings.Valida tionFlags)

The problem is now that even though that there is not a
d-mr:NotaValidVar iable 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 XmlSchemaValida tor [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****@discuss ions.microsoft. comwrote in message
news:9F******** *************** ***********@mic rosoft.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:typedMe mber dimension="d-ty:NationalMark etDimension">
<d-ty:NationalMark et>base metals</d-ty:NationalMark et>
</xbrldi:typedMem ber>

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

validator.Valid ateAttribute(re ader.name, reader.Namespac eURI,
reader.valueval ue, schemainfo)

It validates the name "dimension" correctly with the correct namespace,
however, the value "d-ty:NationalMark etDimension" 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:NationalMark etDimension' 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
1392
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 PartnerML is supplied in several modules, brought together by <xs:include> and <xs:import> statements. My understanding (and experiment) suggests that XMLSpy can't work with such a modularized schema. As a result, my XSLT documents have a header...
4
1491
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 understand! Please, someone, set me right. Thank you, Ian
0
1240
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 reason for that is possibly because, the same namespace URI can have multiple prefixes. But the problem I am facing is, the xpath definition specified for key, keyref and unique elements use the namespace prefixes and these are not converted to the...
19
16137
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" xmlns:sns="http://www.test.org/sub" xmlns:mns="http://www.test.org/mini"> <data>
1
2419
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 was unable to get it fail if a field was blank. My problem now is that while my custom validation control will detect if a field matches my requirement and will display a error message if it doesnt, it wont stop it from being used and sent to my...
2
3475
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 http://www.mycompany.com/division/app? 2) Should I use namespace prefixes? I thought I read something using prefixes is a bad idea? 3) etc. Thanks in advance.
6
2731
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 event handler is not called even when the XML should valid properly against the schema. Obviously I'm missing something. Can anyone help?
3
6885
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 XPATH examples to try and retrieve the "><Code>12455</Code>", but have been unable to do so. The MSDN example works fine. So, I am wondering if it's a namespace issue? Any help would be appreciated. Thanks. Jeff
6
2244
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 use of "using namespace std;" to get rid of that namespace. In fact, "using namespace ..." is very popular with all documentation and example code of most C++ libraries out there which use their own namespace. This raises the question why use...
0
8069
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
8503
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8160
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
8358
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...
1
6017
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3972
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
4036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1339
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.