KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Is there some sensible way to have elements with strongly-typed simple-types and also attributes? Okay, I have an XSD schema which has a million (er, hundred) elements that might look like this: <xsd:element name="DocumentDescription" type="xsd:string" /> <xsd:element name="DocumentDateTime" type="xsd:dateTime" /> <xsd:element name="DocumentSize" type="xsd:int" /> That's dandy. However, I really want all of these elements to also have some common attributes on them like, let's say, "format" and "isVisible". i.e. have a schema like: <DocumentDescription isVisible="true">doc description</DocumentDescription> <DocumentDateTime format="dd/mm/yyyy" isVisible="true">1/1/2008</DocumentDescription> <DocumentSize format="0.00 KB" isVisible="false">5403</DocumentSize> I could do it manually, and horribly, by adding all such attributes to the XSD when I generate it, something like this: <xsd:element name="DocumentDescription" /> <xsd:complexType> <xsd:simpleContent> <xsd:extension base="xsd:string"> <xsd:attribute name="format" type="xsd:string" /> <xsd:attribute name="isVisible" type="xsd:boolean" /> </xsd:extension> </xsd:simpleContent> </xsd:complexType> <xsd:element name="DocumentDateTime" /> ... etc ...but in an ideal world I'd rather define it as a complexType: <xsd:complexType name="customType"> <xsd:complexContent> <xsd:extension base="???"> <xsd:attribute name="format" type="xsd:string" /> <xsd:attribute name="isVisible" type="xsd:boolean" /> ...which means I could just do: <xsd:element name="DocumentDescription" type="customType" baseType="xsd:string" /> <xsd:element name="DocumentDateTime" type="
Tags (comma-separated)
Save Edits
Cancel