[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: DOCTYPE


change doctype
If you are asking if you can supply the DTD for a parser to use at runtime, then consult the
parser documentation. You may not even need to change any text, but just provide a
CATALOG file (to remap the declaration) or supply a command-line parameter.

If you are asking for an algoithm to let you safely insert a DOCTYPE declaration 
on the fly yourself, following is a quick stab. It should be good enough if you are just 
serializing elements. Start by assuming there is already no DOCTYPE declaration and 
that any PIs or comments don't have < in them.

  * Search for the first "<" not followed by "!", "?" or whitespace. 
  * If the next character is "/" then that is an end-tag and your document is not well-formed
  * Store the string on the current line until the first white space or ">" or "/" character.
     That is the first elements name.
  * Insert your DOCTYPE declaration with that string, immediately before that
     first "<" (*not* at the start of the file: this way you preserve any XML headers
     and stylesheet PIs)
  * Make each of the 4 examples below into XML documents, and test your routine
     on each of them. They each test some common edge cases.

---
<x/>
-----
 <x></x >
-----
<?xml version="1.0" ?>
<!-- a comment -->
  <a
/>

------
  <abcdef:ghij  xmlns:ghjij="klmno://pqrst/uvw.xyz " >
      <x />
   </abcdef:ghij>
-------

Cheers
Rick Jelliffe

----- Original Message ----- 
From: "Rupa Kulkarni" <rupali@a...>
To: <xml-dev@l...>
Sent: Wednesday, April 24, 2002 7:49 PM
Subject:  DOCTYPE


Hi
  
   Can I generate the <!DOCTYPE xxxx SYSTEM "xx.dtd">  instruction at run time ???

Rupa


  • References:
    • DOCTYPE
      • From: "Rupa Kulkarni" <rupali@a...>

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.