473,544 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

add CDATA element to an xml schema?

I am creating an xml schema, and I want one of the elements to include
html text. Therefore, I want to make that element a CDATA elements so
that it can accept html tags as part of it's value. I'm having
trouble doing this though. Can anyone give me a sample of how to do
that?

so if this is my xml instance:

<root>
<element><!CDAT A[something]]></element>
</root>

how would I create an xml schema so that my instance is valid against
that schema?
Jul 20 '05 #1
2 14316
In article <2e************ **************@ posting.google. com>,
X. Lee <xh***@yahoo.co m> wrote:
<root>
<element><!CDA TA[something]]></element>
</root> how would I create an xml schema so that my instance is valid against
that schema?


CDATA sections are just a mechanism for escaping character data, so
as far as the schema is concerned it's no different from an element
containing ordinary text.

There's no way to *require* that the user use a CDATA section.

-- Richard
Jul 20 '05 #2
X. Lee wrote:
I am creating an xml schema, and I want one of the elements to include
html text.
You mean HTML markup? In general, this is A Bad Idea. If the markup is
important, represent it in the schema. If it's not, remove it.
Therefore, I want to make that element a CDATA elements so
that it can accept html tags as part of it's value. I'm having
trouble doing this though. Can anyone give me a sample of how to do
that?
You can't do this in XML. If you want to declare CDATA content you have
to use SGML instead, eg

<!element foo - - CDATA>

but even so most SGML parsers will reject any attempt to use an end-tag
inside the element.
so if this is my xml instance:

<root>
<element><!CDAT A[something]]></element>
</root>

how would I create an xml schema so that my instance is valid against
that schema?


Doing it that way (with a manually-inserted CDATA Marked Section) is fine
(except you're missing an open-square bracket before the keyword CDATA).
The instance will always be valid, because the parser will suspend the
recognition of < and & until it encounters ]]>.

///Peter
--
"The cat in the box is both a wave and a particle"
-- Terry Pratchett, introducing quantum physics in _The Authentic Cat_
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1990
by: Isaac Councill | last post by:
Hello, This seems like a newbie question, but I couldn't find the answer on google. I've been using xsl to transform rdf files into runnable programs in another (non-markup) language. It's been great except for a minor hiccup - all text within CDATA blocks shows up at the end of my output files without being invited. I think I've boiled...
0
2076
by: Dimitre Novatchev | last post by:
You seem to be unaware of the xslt processing which uses the built-in rules in the absence of templates that match some selected node. http://www.w3.org/TR/xslt#built-in-rule According to the XSLT processing model: http://www.w3.org/TR/xslt#section-Processing-Model the root node will be processed by a built-in rule, because you do not
0
2752
by: Janne | last post by:
Has anybody else noticed the following bug (?) in JAXB (Sun reference implementation): If you use the type "xs:token" in the xml schema that specifies the element, all white spaces inside the corresponding element of the instance document (*.xml) are condensed into one space-character from the parsed XML file, _even if_ you use the CDATA...
1
3360
by: Stephan Wehner | last post by:
If an XSD schema file says <xs:simpleType name="EXAMPLETYPE"> <xs:restriction base="xs:string"> <xs:minLength value="4"></xs:minLength> <xs:maxLength value="4"></xs:maxLength> </xs:restriction> </xs:simpleType> : :
1
1892
by: pshymon123 | last post by:
I would like to add an element with a CDATA in it but I cannot seem to add it. Firstly I add this to my XML Schema:- <xsd:element name="test" type="xsd:string"/> then I add to my XML document:- <test> <]>
0
2178
by: Douha | last post by:
Hi all, I have an XML file where all to elements for the data are contained in CDATA sections. I have a schema created that is working right now although it is pretty dumbed down. I have a need now to insert into the schema a restriction on the length of the values in the different elements. The xml looks like this; <DOC_CAT...
1
4016
by: soccerdad | last post by:
I've got a class hierarchy generated from a .xsd schema file using the XSD.EXE tool. One of the elements will have its "inner text" set to a CDATA block. The XSD.EXE tool exposed a "Value" property on that element to allow setting that inner text. After I create the object hierarchy and specify all the appropriate elements, attributes, etc., I...
12
3962
by: Peter Michaux | last post by:
Hi, I am experimenting with some of the Ruby on Rails JavaScript generators and see something I haven't before. Maybe it is worthwhile? In the page below the script is enclosed in //<!]> Is this trick grounded in any real information about HTML vs XHTML? I
3
11368
by: Kenny | last post by:
Hey, Is there some way to CDATA an element in an XSD? I'm having an incredibly hard time finding a solution. -Kenny
0
7437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7373
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7389
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5306
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3427
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1848
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.