Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > No way to use entities in a document using schema?

Reply
Thread Tools

No way to use entities in a document using schema?

 
 
Kent Tong
Guest
Posts: n/a
 
      02-19-2004
Hi,

This is wha I'm trying to do:

<?xml version="1.0"?>
<!DOCTYPE library [
<!ENTITY foo "Some sentence...">
]>
<library xmlns="http://foo.com">
&foo;
</library>

But Xerces is saying that "library" element type is undefined. I can
understand that as library is defined in the "http://foo.com"
namespace. Does it means that it is impossible to use entities in
a document using schema/namespace?

If it is true, then it is impossible to split a large xml file into
several small files and then include them as external entites?

Thanks for any advice!
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      02-19-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Kent Tong) wrote in message news:<(E-Mail Removed). com>...
> Hi,
>
> This is wha I'm trying to do:
>
> <?xml version="1.0"?>
> <!DOCTYPE library [
> <!ENTITY foo "Some sentence...">
> ]>
> <library xmlns="http://foo.com">
> &foo;
> </library>
>
> But Xerces is saying that "library" element type is undefined. I can
> understand that as library is defined in the "http://foo.com"
> namespace. Does it means that it is impossible to use entities in
> a document using schema/namespace?
>
> If it is true, then it is impossible to split a large xml file into
> several small files and then include them as external entites?
>
> Thanks for any advice!


If I understand well, you don't want to do validation here at all.
Just suppress validation -- the parser will still read the DTD and
will correctly substitute the value of the entity for every occurence
of its entity reference.


Cheers,

Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
Reply With Quote
 
 
 
 
Kent Tong
Guest
Posts: n/a
 
      02-20-2004
(E-Mail Removed) (Dimitre Novatchev) wrote in message news:<(E-Mail Removed). com>...
> (E-Mail Removed) (Kent Tong) wrote in message news:<(E-Mail Removed). com>...
> If I understand well, you don't want to do validation here at all.
> Just suppress validation -- the parser will still read the DTD and
> will correctly substitute the value of the entity for every occurence
> of its entity reference.


No, I am not trying to surpress validation. I want validation.

What I am trying to do is:
1. to introduce an entity to represent a long sentence that
would be used in many places.
2. to let different people work on different XML files and
then include the files into the main XML file.
 
Reply With Quote
 
Dimitre Novatchev
Guest
Posts: n/a
 
      02-20-2004
(E-Mail Removed) (Kent Tong) wrote in message news:<(E-Mail Removed). com>...
> (E-Mail Removed) (Dimitre Novatchev) wrote in message news:<(E-Mail Removed). com>...
> > (E-Mail Removed) (Kent Tong) wrote in message news:<(E-Mail Removed). com>...
> > If I understand well, you don't want to do validation here at all.
> > Just suppress validation -- the parser will still read the DTD and
> > will correctly substitute the value of the entity for every occurence
> > of its entity reference.

>
> No, I am not trying to surpress validation. I want validation.
>
> What I am trying to do is:
> 1. to introduce an entity to represent a long sentence that
> would be used in many places.
> 2. to let different people work on different XML files and
> then include the files into the main XML file.


Then you have to write the DTD to describe the structure of this
document type and the real names of the elements.

Unfortunately, DTD's are not namespace aware, therefore namespaces are
defined as attributes.

Here's the correct DTD for your document:

<!DOCTYPE library [
<!ENTITY foo "Some sentence...">
<!ELEMENT library (#PCDATA)>
<!ATTLIST library xmlns CDATA #FIXED
"http://foo.com" >

]>
<library xmlns="http://foo.com">
&foo;
</library>

You can check that now the validation is successful.

I'd greatly recommend a good book on XML -- the one that I have
recently read is:

"Effective XML, 50 Specific Ways to Improve Your XML", by Elliotte
Rusty Harold.

This is a great book that goes deep into many advanced topics of XML.


Hope this helped.


Cheers,

Dimitre Novatchev [XML MVP],
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems trying to XSL transform a document with entities. annoyed tuna XML 3 04-20-2005 10:03 PM
Easy way to remove HTML entities from an HTML document? Robert Oschler Python 8 07-31-2004 02:03 AM
HTML::Entities::encode() returning wrong(?) entities Jim Higson Perl Misc 3 07-25-2004 09:13 PM
RE: Easy way to remove HTML entities from an HTML document? Robert Brewer Python 0 07-25-2004 08:21 PM
Including entities file in an xml document chak XML 1 05-13-2004 09:05 PM



Advertisments