Re: NSXML and DTD
Re: NSXML and DTD
- Subject: Re: NSXML and DTD
- From: Matt Neuburg <email@hidden>
- Date: Sat, 09 Sep 2006 10:12:35 -0700
- Thread-topic: NSXML and DTD
On Fri, 8 Sep 2006 15:47:17 -0400, Niels Meersschaert
<email@hidden> said:
>I'm trying to validate an xml document against an external DTD on
>Tiger. I need to be able to validate it against a given external
>DTD, whether or not the source xml declares the same DTD. What I've
>tried is this:
>
>Construct a new DTD
>
>NSXMLDTD *newDTD = [[NSXMLDTD alloc] initWithContentsOfURL:dtdPath
>options:nil error:nil];
>[xml setDTD:newDTD];
>
>If I print out the xml document as it currently exists using
>
>NSLog(@"Document now looks like:\n%@",[xml
>XMLStringWithOptions:NSXMLNodePrettyPrint]);
>
>I see a Doctype declaration with all the elements in my original
>source DTD at the dtdPath. However, there isn't a root element
>declared:
>
><!DOCTYPE [
> <!ELEMENT foo (bar)*>
> <!ELEMENT bar (#PCDATA)>
>]>
><foo>
><bar>Stuff</bar>
><bar>More stuff</bar>
></foo>
>
>If I try to validate it using [xml validateAndReturnError:&error]; I
>get an error:
>
>xml failed validation: NSError "no DTD found!
>" Domain=NSXMLParserErrorDomain Code=1 UserInfo=
>{NSLocalizedDescription = "no DTD found!\n"; }
>
>I think it needs to have the root element defined such that the xml
>looks like:
>
><!DOCTYPE foo [
> <!ELEMENT foo (bar)*>
> <!ELEMENT bar (#PCDATA)>
>]>
><foo>
><bar>Stuff</bar>
><bar>More stuff</bar>
></foo>
>
>How do I set the root element in the doctype? I see no methods for
>this in either the NSXMLDTD or NSXMLDocument classes. Am I missing
>something?
Is this not the same issue that you dealt with previously?
<http://www.cocoabuilder.com/archive/message/cocoa/2006/4/4/160269>
But perhaps there is a difference that I'm missing, in which case, I
apologize. m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden