Actually I had that wrong. The basic example I provided does in fact work;
my problem is that I have a string generated by an object method, and that
method automatically places the quotation mark at the end of my string.
That's the quotation mark that I don't know how to remove. I should have
provided the real world example, sorry about that.

If I do the following, I get one extraneous quotation mark at the end of my
doctype declaration, and I'm not sure how to take it out. If I don't, the
path is invalid and the document can't be processed with a stylesheet. Any
idea how to get rid of the trailing quotation mark?

#########################################################
#!/usr/bin/perl
use IO;
use XML::Writer;

my $urn = qq(urn:newsml:iptc.org:20001006:NewsMLv1.0:1);
my $dtd = qq(/path/to/NewsMLv1.0.dtd");
my $elements = qq( [<!ELEMENT CompanyName (#PCDATA)>
<!ELEMENT Category (#PCDATA)>]);
$dtd = $dtd . $elements;

my $output = new IO::File(">myfile.xml");
my $writer = new XML::Writer(OUTPUT => $output);
$writer->xmlDecl("UTF-8");
$writer->doctype("NewsML", $urn, $dtd);
#########################################################

Here is the resulting doctype declaration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NewsML PUBLIC "urn:newsml:iptc.org:20001006:NewsMLv1.0:1"
"/path/to/NewsMLv1.0.dtd"
 [<!ELEMENT CompanyName (#PCDATA)>
  <!ELEMENT Category (#PCDATA)>]">

Notice the " right before the closing tag of the doctype. Since the $writer
object is adding that, is it possible to use the object to extract it? If
so, I am not sure how - any ideas or suggestions?

Also, the addition of the quote here

        my $dtd = qq(/path/to/NewsMLv1.0.dtd");

is intentional. Otherwise, the entire element list is included in the path
to the DTD, which would be incorrect.

I tried adding the doctype declaration by printing a HERE document, but
since I wasn't passing data to the object writing the XML, that was ignored.

Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
[EMAIL PROTECTED]
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.349 / Virus Database: 195 - Release Date: 4/15/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to