You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Dean Roddey <dr...@charmedquark.com> on 2001/09/01 02:10:32 UTC

Re: void XMLURL::setURL(const XMLCh* const urlText)

You can only set the primary entity (the one you pass in to parse) via an
input source.

The thing is that the URL class is an OO class and is general purpose and
should use exceptions to report errors. What is needed is not to hack up the
URL class and make it less desirable, but to provide external optimizations
that prevent it from being used such that it would create exceptions unless
they are for real.

A bit of probing could quickly determine the correct thing most of the time.
For instance, if it starts with a '.', then its relative which means its of
the type of its parent, which is known. That would handle many of the cases,
since the parser could then internally use the correct type of input source
and avoid this issue. If it starts with http or ftp, then its its a URL. If
it starts with x: or / then its a local file.

--------------------------
Dean Roddey
The Charmed Quark Controller
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"If it don't have a control port, don't buy it!"


----- Original Message -----
From: "Murphy, James" <Ja...@excelergy.com>
To: <xe...@xml.apache.org>
Sent: Friday, August 31, 2001 1:59 PM
Subject: RE: void XMLURL::setURL(const XMLCh* const urlText)


> Hmm.  I mean external entities like schemas? iif I have:
>
> <bar xmlns = "foo" schemaLocation="foo c:\schemas\foo.xsd">
>  ...
> </bar>
>
> with validation on "c:\schemas\foo.xsd" is parsed like a url first and an
> exceptionis thrown.  Are you saying I have set the schema location
manually
> using a LocalFileInputSource?
>
> Jim
>
> > -----Original Message-----
> > From: Dean Roddey [mailto:droddey@charmedquark.com]
> > Sent: Friday, August 31, 2001 4:51 PM
> > To: xerces-c-dev@xml.apache.org
> > Subject: Re: void XMLURL::setURL(const XMLCh* const urlText)
> >
> >
> > Use LocalFileInputSource to pass in your file names, then the
> > parser won't
> > have to figure it out itself.
> >
> > --------------------------
> > Dean Roddey
> > The Charmed Quark Controller
> > Charmed Quark Software
> > droddey@charmedquark.com
> > http://www.charmedquark.com
> >
> > "If it don't have a control port, don't buy it!"
> >
> >
> > ----- Original Message -----
> > From: "Murphy, James" <Ja...@excelergy.com>
> > To: <xe...@xml.apache.org>
> > Sent: Friday, August 31, 2001 8:05 AM
> > Subject: void XMLURL::setURL(const XMLCh* const urlText)
> >
> >
> > > I really wish[1] didn't throw an exception when parsing a
> > pathname instead
> > > of a url.  Just returning false would be better in my view.
> >  This creates
> > > 6-10 exception per parse for use since we _always_ have
> > file paths not
> > urls
> > > for our schema locations.  It really muddies up debugging.
> > >
> > >  A couple of spots to bubble up the return code would be easy but
> > eventually
> > > end when the constructor throw an exception.  I'm not a big
> > fan of that
> > > behavior either.
> > >
> > > Thoughts?
> > >
> > > Jim
> > >
> > >
> > > [1] void XMLURL::parse(const XMLCh* const urlText)
> > >
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: AW: Include XML-files

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Ing. Hans Pesata" <hp...@chello.at> writes:

> Hi !
> 
> // You can include dtd files in the same way.
> // Like this:
> //
> // <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
> //
> // <!DOCTYPE configuration SYSTEM "test.dtd"
> // [
> // 	<!ENTITY xmlfile SYSTEM "test1.xml">
> // 	<!ENTITY % dtdfile SYSTEM "test1.dtd">
> //       %dtdfile;
> // ]>
> //
> // <configuration>
> //
> // 	<sections>
> // 		<section name="Default-Values">
> // 			<file>&xmlfile;</file>
> // 		</section>
> // 	</sections>
> //
> // </configuration>
> //
> // The entity dtdfile will be expanded immediatly when it is seen
> // and thereby
> // loading the file test1.dtd during the DTD parsing.
> // Note this is pure "this should work". I have not tested it myself.
> 
> the only problem is see with this approach is, that the DTD-file is
> not bound to the included XML-file and so I cant make sure, that the
> included XML-file is 100% validated correctly.


This is incorrect. The function of the entities is just so you can
store the definitions in an external file. So the behavior is
identical to what you would see if you had placed the contents of
dtdfile directly in the internal subset, and xmlfile in the
text. Therefore the contents of xmlfile are validated using the
combined contents of test1.dtd and dtdfile. That is as tight a binding
as you can get.

jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


AW: AW: Include XML-files

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

Thanx a lot for the replies !

// If you want it that finely controlled, you have to parse the files
// separately and then combine the DOM trees (import one into the other).
// Ciao, Jürgen

I will be using SAX, because it fits better into the approach my app uses.

// This is incorrect. The function of the entities is just so you can
// store the definitions in an external file. So the behavior is
// identical to what you would see if you had placed the contents of
// dtdfile directly in the internal subset, and xmlfile in the
// text. Therefore the contents of xmlfile are validated using the
// combined contents of test1.dtd and dtdfile. That is as tight a binding
// as you can get.
// jas.

I understand that this is just somekind of splitting the whole
XML/DTD-data into several parts.

What I meant to say was, that there is no exact binding of
TEST1.XML with TEST1.DTD, TEST1.XML is parsesd according to the
mixed information from TEST.DTD and TEST1.DTD.

So I can define elements from TEST.DTD within TEST1.XML, for example.

But probably using namespaces, as Erik suggested, will do the trick.
I have to look into this.

Best regards,
Hans Pesata



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: AW: Include XML-files

Posted by Juergen Hermann <jh...@web.de>.
On Tue, 4 Sep 2001 09:46:22 +0200, Ing. Hans Pesata wrote:

>the only problem is see with this approach is, that the DTD-file
>is not bound to the included XML-file and so I cant make sure,
>that the included XML-file is 100% validated correctly.

If you want it that finely controlled, you have to parse the files 
separately and then combine the DOM trees (import one into the other).


Ciao, Jürgen



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


AW: Include XML-files

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

// You can include dtd files in the same way.
// Like this:
//
// <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
//
// <!DOCTYPE configuration SYSTEM "test.dtd"
// [
// 	<!ENTITY xmlfile SYSTEM "test1.xml">
// 	<!ENTITY % dtdfile SYSTEM "test1.dtd">
//       %dtdfile;
// ]>
//
// <configuration>
//
// 	<sections>
// 		<section name="Default-Values">
// 			<file>&xmlfile;</file>
// 		</section>
// 	</sections>
//
// </configuration>
//
// The entity dtdfile will be expanded immediatly when it is seen
// and thereby
// loading the file test1.dtd during the DTD parsing.
// Note this is pure "this should work". I have not tested it myself.

thanx for the hint, it works.

the only problem is see with this approach is, that the DTD-file
is not bound to the included XML-file and so I cant make sure,
that the included XML-file is 100% validated correctly.

I understand, that the 2nd DTD is just loaded and not connected to the
included XML-file,
so the included XML-file could also contain elements of the 1st DTD, altough
they
are not valid within this file.

Is there a possibilty to connect the 2 files e.g. by placing the %dtdfile
somewhere else
within the XML-file ?

Regards,
Hans Pesata



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


RE: Include XML-files

Posted by Erik Rydgren <er...@mandarinen.se>.
You can include dtd files in the same way.
Like this:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<!DOCTYPE configuration SYSTEM "test.dtd"
[
	<!ENTITY xmlfile SYSTEM "test1.xml">
	<!ENTITY % dtdfile SYSTEM "test1.dtd">
      %dtdfile;
]>

<configuration>

	<sections>
		<section name="Default-Values">
			<file>&xmlfile;</file>
		</section>
	</sections>

</configuration>

The entity dtdfile will be expanded immediatly when it is seen and thereby
loading the file test1.dtd during the DTD parsing.
Note this is pure "this should work". I have not tested it myself.

Good luck.

Erik Rydgren
Mandarinen systems AB
Sweden


-----Original Message-----
From: Ing. Hans Pesata [mailto:hpesata@chello.at]
Sent: den 3 september 2001 13:41
To: xerces-c-dev@xml.apache.org
Subject: AW: Include XML-files


Hi !

I realized, that it is not possible to use external entities within
attributes,
so I triedusing the include for my external XML-file within an element
and this works.

Another thing I realized is, that I cant use a DTD within
the included XML-file, that means I just can access/use elements already
declared in the 1st DTD ?!

my goal was to use an DTD within the included XML-file too.

Is there any possibility to achieve this ?

Regards,
Hans Pesata

-------------------------------
TEST.DTD
-------------------------------

<!ELEMENT	configuration (sections?)>

<!ELEMENT	sections (section*)>
<!ELEMENT	section (file, entries?)>
<!ATTLIST	section
		name	CDATA	#REQUIRED>
<!ELEMENT	file ANY>

<!ELEMENT	entries (entry*)>
<!ELEMENT	entry EMPTY>
<!ATTLIST	entry
		name	CDATA	#REQUIRED>

-------------------------------
TEST.XML
-------------------------------

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<!DOCTYPE configuration SYSTEM "test.dtd"
[
	<!ENTITY xmlfile SYSTEM "test1.xml">
]>

<configuration>

	<sections>
		<section name="Default-Values">
			<file>&xmlfile;</file>
		</section>
	</sections>

</configuration>

-------------------------------
TEST1.XML
-------------------------------

<entries>
	<entry name="1"/>
	<entry name="2"/>
	<entry name="3"/>
</entries>



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


AW: Include XML-files

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

I realized, that it is not possible to use external entities within
attributes,
so I triedusing the include for my external XML-file within an element
and this works.

Another thing I realized is, that I cant use a DTD within
the included XML-file, that means I just can access/use elements already
declared in the 1st DTD ?!

my goal was to use an DTD within the included XML-file too.

Is there any possibility to achieve this ?

Regards,
Hans Pesata

-------------------------------
TEST.DTD
-------------------------------

<!ELEMENT	configuration (sections?)>

<!ELEMENT	sections (section*)>
<!ELEMENT	section (file, entries?)>
<!ATTLIST	section
		name	CDATA	#REQUIRED>
<!ELEMENT	file ANY>

<!ELEMENT	entries (entry*)>
<!ELEMENT	entry EMPTY>
<!ATTLIST	entry
		name	CDATA	#REQUIRED>

-------------------------------
TEST.XML
-------------------------------

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<!DOCTYPE configuration SYSTEM "test.dtd"
[
	<!ENTITY xmlfile SYSTEM "test1.xml">
]>

<configuration>

	<sections>
		<section name="Default-Values">
			<file>&xmlfile;</file>
		</section>
	</sections>

</configuration>

-------------------------------
TEST1.XML
-------------------------------

<entries>
	<entry name="1"/>
	<entry name="2"/>
	<entry name="3"/>
</entries>



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


AW: Include XML-files

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

// Actually, this is a very typical question, and yes, you use external
// entities. Instead of defining them in your DTD (i.e. the external
// subset), you use the internal subset within your XML document:
//
// <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
// <!DOCTYPE classes SYSTEM 'classes.dtd' [
//   <!ENTITY Person SYSTEM "Person.xml" >
//   <!ENTITY Security SYSTEM "Security.xml" >
//   <!ENTITY Audit SYSTEM "Audit.xml" >
//   <!ENTITY Organization SYSTEM "Organization.xml" >
//   <!ENTITY SecurityGroup SYSTEM "SecurityGroup.xml" >
//   <!ENTITY Contact SYSTEM "Contact.xml" >
//
// ]>
// <classes>
// &Person;
// &Security;
// &Audit;
// &Organization;
// &SecurityGroup;
// &Contact;
//
// </classes>
//
// HTH,

Thanx for your reply!

I need a slightly different approach, than the one you suggested.
I need to use the entity-value in an attribute of another object than the
root-object:

-------------------------------------------
TEST.DTD
-------------------------------------------

<!ELEMENT	configuration (sections?)>

<!ELEMENT	sections (section*)>
<!ELEMENT	section EMPTY>
<!ATTLIST	section
			name	  CDATA	#REQUIRED
			xmlfile ENTITY	#REQUIRED>

-------------------------------------------
TEST.XML
-------------------------------------------

<?xml version="1.0" standalone="no"?>

<!DOCTYPE configuration SYSTEM "test.dtd"
[
	<!ENTITY xmlfile SYSTEM "section.xml">
]>

<configuration>

	<sections>
		<section name="Default-Values" xmlfile="xmlfile"/>
	</sections>

</configuration>

-------------------------------------------

this doesnt work, because the entity isnt defined within the DTD...

Best regards,
Hans Pesata



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Include XML-files

Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Ing. Hans Pesata" <hp...@chello.at> writes:

> I know this is not a typical XERCES-related question,
> but I would like to know, if and how it is possible to include
> XML-files with other XM-files ?!
> 
> I read about external entities, but these must be defined with a DTD
> and not within my XML-file ?!

Actually, this is a very typical question, and yes, you use external
entities. Instead of defining them in your DTD (i.e. the external
subset), you use the internal subset within your XML document:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE classes SYSTEM 'classes.dtd' [
  <!ENTITY Person SYSTEM "Person.xml" >
  <!ENTITY Security SYSTEM "Security.xml" >
  <!ENTITY Audit SYSTEM "Audit.xml" >
  <!ENTITY Organization SYSTEM "Organization.xml" >
  <!ENTITY SecurityGroup SYSTEM "SecurityGroup.xml" >
  <!ENTITY Contact SYSTEM "Contact.xml" >

]>
<classes>
&Person;
&Security;
&Audit;
&Organization;
&SecurityGroup;
&Contact;

</classes>
 
HTH,
jas.

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Include XML-files

Posted by "Ing. Hans Pesata" <hp...@chello.at>.
Hi !

I know this is not a typical XERCES-related question,
but I would like to know, if and how it is possible to include
XML-files with other XM-files ?!

I read about external entities, but these must be defined with a DTD
and not within my XML-file ?!

I am currently working on a project which will be using XERCES C++ using
XML-files with external DTDs
and (hopefully) possible includes.

If this is possible, how can I achieve this with XERCES ?
I will be using a SAX/SAX2 parser within my project.

Any help with this would be greatlya apprecited,
thanx in advance!

Regards,
Hans Pesata



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org