• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Schemas and CDATA

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an XML document that looks like this:

...
<someTag>123</someTag>
<fileContent><![CDATA[ABC 123 456
DEF 333 444
FKL 777 888]]></fileContent>
...

How do I create an XML schema that reads that fileContent CDATA?

My first shot is like this:

<xsd:element name="fileContent">
<xsd:complexType>
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="dtype" type="CDATA"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
</xsd:element>

Am I close?
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quick answer is, nope you are not close.
You defined the fileContent as an
element with CDATA content.
But in the schema, you seem to put the
CDATA into an attribute attached to this
element.

As to the correct way, I will have to put
that off till tomorrow morning, sorry.
My copy of the Schema book is at work and I will take
a look at this tomorrow morning.
Thanks.

- m
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to the book, the type CDATA in a DTD maps to a normalizedString in the Schema.

So your element should be defined in the schema to be of type....

- m
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic