469,290 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,290 developers. It's quick & easy.

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 2733


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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by ian.rutgers | last post: by
2 posts views Thread by steve | last post: by
6 posts views Thread by lists | last post: by
3 posts views Thread by =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.