• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSXML and DTD
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSXML and DTD


  • Subject: NSXML and DTD
  • From: Niels Meersschaert <email@hidden>
  • Date: Fri, 8 Sep 2006 15:47:17 -0400

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?


Thanks,

Niels


Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: NSXML and DTD (SOLVED)
      • From: Niels Meersschaert <email@hidden>
  • Prev by Date: cursor rects
  • Next by Date: Re: Crash in NSPopUpbuttonCell
  • Previous by thread: cursor rects
  • Next by thread: Re: NSXML and DTD (SOLVED)
  • Index(es):
    • Date
    • Thread