venta: (Default)
[personal profile] venta
I'm writing My First XML Schema... it's for a very simple family of XML documents which someone else has defined by saying "yes, well, it's all fairly self-explanatory".

(He's right, it is, though documenting that is actually quite hard.)

However, there is an elephantelement whose value is an ASN.1 GeneralizedTime. How do I express in the schema that that should be the case ?

I can do:

<element name="partyTime" type="xsd:dateTime" minOccurs="0"/>

... but that's not the same thing. How do I refer to ASN.1 entities from inside an XML schema ? ASN.1 does provide a method to encode GeneralizedTime objects into xsd:dateTime format, but I can't see how that's useful.

Or do I just call a GeneralizedTime a string and have done with it?

Date: 2008-09-10 05:23 pm (UTC)
From: [identity profile] leathellin.livejournal.com
Well there are a couple of things you can do -

1) Use a very loose validation of ASN.1 GeneralizedTime in the schema such as string and validation/document the format of the XML element is correct else where. This plan tends to be less favoured by me but if the documents you are writing schemas for aren't that complicated otherwise and there is plenty of format validation else where it might be the easiest solution.

2) Create a pattern facet covering some of the formatting rules so that at least glaringly bad data is caught by schema validation and do detailed date and time validation/documentation else where. The downside is of course that validation of the format is split between schema and code.

3) Make it a dateTime as you have said above and transform the format into the correct one for the XML allowing the schema validation to validate all the data type rules but requiring transformation of the data format. Not actually that much effort if you're already transforming back and forth to create the XML in the first place.

You do not appear to be the first person to attempt to map ASN.1 to XML Schema so depending on what you are doing this previous attempt may help you avoid making decisions yourself http://xml.coverpages.org/ASN1toXMLSchemaWhitePaper.pdf :-)

Profile

venta: (Default)
venta

December 2025

S M T W T F S
 123456
78910111213
14151617181920
212223 24252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jan. 7th, 2026 08:06 pm
Powered by Dreamwidth Studios