473,246 Members | 1,928 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,246 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 2094
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: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.