473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DTD or Schema -- Ignore Undefined Tags

I am wondering if there is a way to use a DTD or Schema to instruct an
XML parser to ignore tags that are not defined.

That is, if my list of acceptable tags is <bodyand <content>, then in
the following example:

<body>
We may have some text <b>and some <u>other tags</u></b>
<contentbut I want the text and undefined tags to be part of the
text-node
of the body tag.
</content>
</body>

So the tree would be like:
<body>
#Text
<content>
#Text
</content>
</body>

I want the first text node to contain "We may have some text <b>and
some <u>other tags</u></b>"

Is there some way of doing this with Schemas or DTDs? Or perhaps using
a stylesheet?

Using a stylesheet I would need to do find a way of matching all tags
that arent in a certain list and then re-writing them with $lt;
entities I suppose, but I'm really not sure what the best way to do
this is.

Any help is appreciated,

Greg

Dec 14 '06 #1
2 2098
gr************@gmail.com wrote:
Using a stylesheet I would need to do find a way of matching all tags
that arent in a certain list and then re-writing them with $lt;
entities I suppose
Not a good solution. Elements are semantically meaningful; &lt;foo&gt;
is NOT the same thing as <foo>.

If you're working with schemas, you can use xsd:any with lax validation
to indicate that the contents of certain elements should be accepted
even if not valid.

Another alternative, of course, is to insist only on well-formed
documents and not attempt to validate them.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Dec 14 '06 #2
gr************@gmail.com wrote:
I am wondering if there is a way to use a DTD or Schema to instruct an
XML parser to ignore tags that are not defined.
No.A schema or DTD is for doing exactly the reverse: enforcing the use
only of elements that have been declared.

BTW elements, not "tags": see http://xml.silmaril.ie/authors/makeup/
That is, if my list of acceptable tags is <bodyand <content>, then in
the following example:

<body>
We may have some text <b>and some <u>other tags</u></b>
<contentbut I want the text and undefined tags to be part of the
text-node
of the body tag.
</content>
</body>

So the tree would be like:
<body>
#Text
<content>
#Text
</content>
</body>
If you want to do this, process the XML in non-validated mode, just
well-formed but with no DTD or schema.
I want the first text node to contain "We may have some text <b>and
some <u>other tags</u></b>"

Is there some way of doing this with Schemas or DTDs? Or perhaps using
a stylesheet?
XSLT is your friend.
Using a stylesheet I would need to do find a way of matching all tags
that arent in a certain list and then re-writing them with $lt;
entities I suppose, but I'm really not sure what the best way to do
this is.
Whoah! This is a different question entirely. Are you implying that you
still want to *keep* the otherwise unrecognised element markup? Your
example above implied that you wanted to discard it.

You definitely don't want to fiddle with making them all &lt;...&gt; --
that way madness lies. See http://xml.silmaril.ie/authors/html/

///Peter
--
XML FAQ: http://xml.silmaril.ie/
Dec 14 '06 #3

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

Similar topics

6
by: Abhinav | last post by:
Hi, I have an xml which contains the following <a> <!-- aa Is what I am interested in --> <aa> </aa> <bb></bb>
0
by: Philippe Poulard | last post by:
People familiar with DTD, Relax NG, W3C XML Schema, Schematron, and that are aware of more recent works such as DSDL should recognize all of them in the Active Schema Language. Anyway, ASL...
0
by: Jeremy Summers | last post by:
Has anyone run into problems creating typed datasets from complex schemas? I am attempting to create a Typed Dataset in Visual Studio .Net from a .xsd schema file for a industry standard web...
1
by: David C. Allen | last post by:
I am trying to insert an xml data island into a htm file that I am using for a help file. When I insert the lines of xml, the <xml> tag is underlined in red in VS2003 and the message says "The...
2
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to...
0
by: BC3Tech | last post by:
I'm creating a system that uses XML to store an audit trail of the steps that it has been through in the system. The way the schema is defined, there is a "Tag" for every application that...
2
by: Ali | last post by:
I am having problem compiling schema contained in WSDL file when analyzing schema types contained in it (for example http://www.ebout.net/net/GoogleSearch.wsdl). Following code demonstrates my...
5
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail...
3
by: Michael | last post by:
If I come up with an XML Schema, do I own the intellectual propertyrights for that schema? Can I legally restrict others from using that schema? I'm in the UK if that makes any difference...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.