Re: Validating NSXMLDocument with DTD that has ANY condition
Re: Validating NSXMLDocument with DTD that has ANY condition
- Subject: Re: Validating NSXMLDocument with DTD that has ANY condition
- From: "Steve Shepard" <email@hidden>
- Date: Fri, 31 Aug 2007 00:31:52 -0700
Unfortunately, ANY means "any element in the DTD." You're probably
trying to handle unknown elements, and I'm not aware of a solution for
that. XML Schema (which libxml supports but NSXML doesn't) lets you
skip all elements in a known namespace. If you wanted, you could
validate the data with libxml before passing it to NSXML.
-Steve
BTW, a useful tool for debugging DTDs is xmllint:
xmllint --dtdvalid plugin.dtd plugin.xml
On 8/29/07, Jesse Grosjean <email@hidden> wrote:
> Now that I can ready my NSXMLDocument I'm trying to validate it. The
> documents that I"m parsing are well defined, but one type of element
> <extension> should be able to hold any kind of valid XML content. But
> I'm not sure how to validate that, right now I'm getting errors from
> [NSXMLDocument validateAndReturnError] anytime I use an element name
> that isn't explicitly declared in my DTD. For example I get this error:
>
> NSError "No declaration for element applicationWillFinishLaunching
> No declaration for attribute class of element
> applicationWillFinishLaunching
> " Domain=NSXMLParserErrorDomain Code=1 UserInfo={
> NSLocalizedDescription = "No declaration for element
> applicationWillFinishLaunching\nNo declaration for attribute class of
> element applicationWillFinishLaunching\n";
> }
>
> In a document that has a <applicationWillFinishLaunching> element
> declared in the section that should allow ANY elements.
>
> Does anyone know what I need to do to validate my document, but let
> the children of one element type contain any valid XML?
>
> Thanks,
> Jesse
>
> Below I've included the sample XML file that gets the above
> validation error, and I've included the validating DTD below that.
>
> ----------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <plugin
> id="com.blocks.BPreferences"
> label="Preferences"
> version="1.0.0"
> info="Blocks Preferences">
>
> <requirement bundle="com.blocks.Blocks"/>
> <requirement bundle="com.blocks.BLifecycle"/>
> <requirement bundle="com.blocks.BUserInterface"/>
>
> <extension-point id="preferencePanes" />
>
> <extension point="com.blocks.BLifecycle.lifecycle">
> <applicationWillFinishLaunching class="BPreferencesController" />
> </extension>
> </plugin>
>
> ----------------------------------------------
>
> <!ELEMENT plugin (requirement*, extension-point*, extension*)>
> <!ATTLIST plugin
> id CDATA #REQUIRED
> label CDATA #REQUIRED
> version CDATA #REQUIRED
> info CDATA #IMPLIED
> >
>
> <!ELEMENT requirement EMPTY>
> <!ATTLIST requirement
> bundle CDATA #REQUIRED
> version CDATA #IMPLIED
> optional (true | false) "false"
> >
>
> <!ELEMENT extension-point EMPTY>
> <!ATTLIST extension-point
> id CDATA #REQUIRED
> >
>
> <!ELEMENT extension ANY>
> <!ATTLIST extension
> point CDATA #REQUIRED
> >
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden