JMan
JMan

Reputation: 2629

Xbrl Validation

I have a generated XDocument that needs to be validated to Xbrl xsd's I have created a custom XmlResolver to load all the xsd files from the external party.

This is the GetEntity Function from my resolver so i can get the included xsd's:

Public Overrides Function GetEntity(absoluteUri As Uri, role As String, ofObjectToReturn As Type) As Object

    'If absoluteUri.ToString.Contains("www.xbrl.org") Then
    '    Nothing here yet
    'End If

    Dim nmSpace As String = _assembly.GetName.Name.ToString
    Dim resource = String.Concat(nmSpace, ".", Path.GetFileName(absoluteUri.ToString()))
    Dim result = _assembly.GetManifestResourceStream(resource)

    Return result
End Function

However there are a lot of xsd's from the xbrl namespace and they don't get loaded.

I started downloading them to include them as a resource but there are just to many files so it doesn't seem like the best solution.

I hope anyone has some experience in validating an Xbrl file because i feel like i'm missing the point here :)

Upvotes: 1

Views: 1261

Answers (2)

JMan
JMan

Reputation: 2629

www.Arelle.org

This open source project contains a web-service that can be used to validate Xbrl files. This what i implemented right now and it checks against all the required Xbrl rules

Upvotes: 2

JMan
JMan

Reputation: 2629

I'm using plain Xml-Xsd validation and this seems ok so far.

I implemented the custom resolver like this:

Public Class ResourceXmlResolver
Inherits XmlResolver

Private Shared _xmlUrlResolver As XmlUrlResolver = New XmlUrlResolver()
Private _assembly As Assembly

Public Sub New(assembly As Assembly)
    _assembly = assembly
End Sub

Public Overrides Function GetEntity(absoluteUri As Uri, role As String, ofObjectToReturn As Type) As Object

    If absoluteUri.ToString.Contains("www.xbrl.org") Then
        Return _xmlUrlResolver.GetEntity(absoluteUri, role, ofObjectToReturn)
    End If

    Dim nmSpace As String = _assembly.GetName.Name.ToString
    Dim resource = String.Concat(nmSpace, ".", Path.GetFileName(absoluteUri.ToString()))
    Dim result = _assembly.GetManifestResourceStream(resource)

    Return result
End Function
Public Overrides WriteOnly Property Credentials() As System.Net.ICredentials
    Set(value As System.Net.ICredentials)
        Throw New NotImplementedException()
    End Set
End Property

End Class

The Xsd files provided by the third party are embedded resources.

I set the Assembly to the assembly containing my Xsd files, so when the GetEntity method is called by setting the resolver:

Dim schemas As XmlSchemaSet = New XmlSchemaSet()
    schemas.XmlResolver = New ResourceXmlResolver(System.Reflection.Assembly.GetExecutingAssembly)

They are loaded correctly. I do however provide a check for the xsd's from www.xbrl.org.
In that case i'm using the standard XmlUrlResolver to get them from the web.

I also got this working by just downloading all the xbrl xsd's and also embedding them.

I hope this is enough validation for Xbrl but got this working so far :)

Upvotes: 1

Related Questions