You are viewing a plain text version of this content. The canonical link for it is here.
Posted to p-dev@xerces.apache.org by Juan Leon <jl...@leon.com> on 2001/03/08 04:28:31 UTC
Perl samples
Forgive me for intruding with some very basic questions.
I got a xerces perl tarball from hnine@netarx.com. I am trying to
use it
by looking at the Xerces C++ API docs and pretty much guessing how to
call the perl wrappers. I am a swig neophyte and I don't quite
understand
how the bindings work, so I am having some trouble. An example: how
do I call DOMParser::parse with a file name as argument? Looks like
the perl binding is to the constructor that takes an InputSource rather
than a string, but when I try to use FileInputSource in erl I get a core
dump.
Anyway, I figure this and other questions I have would be answered
with the
sample DOMCount.pl which I have seen mentioned but which I have not
found
anywhere. Is there such a sample. Another one that would help me?
Thank you. Please also let me know if there is a mailing list in which
questions
like this would be more appropriate.
Juan Leon
jl+@cs.cmu.edu
Re: Perl samples
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Juan Leon" <jl...@leon.com> writes:
> Forgive me for intruding with some very basic questions.
And an extremely important one, too. Thank you for asking it.
> I got a xerces perl tarball from hnine@netarx.com. I am trying to
> use it by looking at the Xerces C++ API docs and pretty much
> guessing how to call the perl wrappers. I am a swig neophyte and I
> don't quite understand how the bindings work, so I am having some
> trouble. An example: how do I call DOMParser::parse with a file
> name as argument? Looks like the perl binding is to the constructor
> that takes an InputSource rather than a string, but when I try to
> use FileInputSource in erl I get a core dump.
The best I can say at this point is look at the test scripts in the t/
directory. The folks from netarx have been using it and could perhaps
provide us with some example scripts.
> Anyway, I figure this and other questions I have would be answered
> with the sample DOMCount.pl which I have seen mentioned but which I
> have not found anywhere. Is there such a sample. Another one that
> would help me?
It exists, and has not yet been ported to use the Xerces 1.3
interface. If you'd like to volunteer, I'd be very happy to commit it
for you ;-)
> Thank you. Please also let me know if there is a mailing list in
> which questions like this would be more appropriate.
As far as I'm concerned (and I'm a moderator) this is exactly the
place for your question. I sorry I don't have a better answer, but we
just got all the pieces into CVS today.
jas.
Re: Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Harmon S. Nine" <hn...@netarx.com> writes:
> In a marathon session, I was able to work out all the kinks in xerces-perl
> to get it to work with XWIG 1.3. Everything compiles. All the tests work.
>
> I'll be shipping it to Jason and everyone on the list sometime between
> tomorrow and
> Monday.
Alright! that is good news!
Were you using the code I checked in to CVS, or did you recreate it on
your own? Just curious. I'm eager to see how you fixed the other
tests.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
The RTTI module
Posted by Fredrick Paul Eisele <ph...@netarx.com>.
The RTTI module is our first cut at exposing a C++ capability into the Perl
environment.
RTTI, run time type information, implements serveral type/class functions.
dynamic_cast: can cast from a polymorphic base class to a derived or
sibling class. This is implemented as a restricted bless. I should not be
allowed to bless into a class for which certain methods will not be supported.
typeid: returns the class to which an object belongs, i.e. the ref function.
actual_cast: bless an object into the most specific class to which it belongs.
The relevance in Xerces is to provide a means for selectively blessing a
DOM::Node into, for example, the DOM::Element class, according to its
saved type. It happens that a DOM::Node carries its specific class, the
object is blessed into this class, upon calling actual_cast.
schema_cast: (in development) when an XML serialization is parsed it
would be nice if the resulting DOM were blessed into a class.
This could be implemented by reading a URN (namespace?), loading the
appropriate module and blessing the DOM into the package.
i.e. <xyz xmlns="urn:xerces:foo/bar"> would use XML::Xerces::foo::bar;
It is likely that introducing a module to perform these behaviors was ill
conceived and should be rethought. I frequently use the actual_cast method,
which could easily be added to the Xerces.pm without the need for any RTTI.pm.
--
Fredrick Paul Eisele
30910 Telegraph Rd.
Bingham Farms, MI
1.248.647.9800
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Jason E. Stewart" <ja...@openinformatics.com> writes:
> I would like to make the SWIG 1.3 line the official release for
> Xerces.pm-1.3. Because we supply a pre-SWIG'ed Xerces.pm and Xerces.C
> people do not need SWIG to build the module, Xerces.i is only there
> for developers.
It also seems that SWIG 1.3 behaves better in the debugger, I haven't
had any trouble yet, and I've run quite a few scripts and pieces of
test code through the debugger with Xerces.pm...
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Harmon S. Nine" <hn...@netarx.com> writes:
> The RTTI.pm module should really be kept seperate from the
> XML::Xerces namespace. Right now, it performs a function similar to
> "reinterpret_cast<TYPE>" in C++. Theoretically, it could be applied
> to any package (in particular, those generated by SWIG).
I have only some minor qualms:
* I have no real idea what RTTI.pm actually does or why we need it (I
would like to know)
* If it is SWIG specific, that should likely be part of the title,
i.e. SWIG::RTTI
* Creating toplevel namespace modules should be really general, and it
seems that what we have is currently very specific to our needs
* and since the rest of the module get's installed under XML::Xerces,
I don't want to go stomping on somebody else's installation of a
toplevel RTTI.pm module whent they think they are installing a bunch
of stuff that only lives in the XML::Xerces namespace.
> The code-munging exercise is complete for SWIG 1.1. That is,
> postSource.pl and postModule.pl have been modified to place the
> xerces-perl package into the XML::Xerces namespace even though the
> "-package" option in SWIG 1.1 is broken. I'll send you the changes
> ASAP (the only reason I did this was to see if it could be done, and
> because SWIG 1.3 is still alpha).
OK. Thanks. I hope you enjoyed the excercise ;-)
My suggestion:
* I merge in your SWIG 1.1 changes into the branch and we cut another
release.
* Then I merge in the SWIG 1.3 line into the main line and cut
another release.
* update the WWW site
* Then we work on Xerces 1.4
I would like to make the SWIG 1.3 line the official release for
Xerces.pm-1.3. Because we supply a pre-SWIG'ed Xerces.pm and Xerces.C
people do not need SWIG to build the module, Xerces.i is only there
for developers.
> So, if we're in agreement, I'd like to scrap FileInputSource and
> MemoryInputSource. Also, scrapping FileInputSource would render the
> Xerces.C.diff file unnecessary. That would eliminate a headache.
Ah... I like the sound of that ... the sound of the backspace key
deleting unnecessary code ;-)
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Harmon S. Nine" <hn...@netarx.com>.
Jason:
The RTTI.pm module should really be kept seperate from the XML::Xerces
namespace.
Right now, it performs a function similar to "reinterpret_cast<TYPE>" in
C++.
Theoretically, it could be applied to any package (in particular, those
generated by SWIG).
The code-munging exercise is complete for SWIG 1.1. That is,
postSource.pl and
postModule.pl have been modified to place the xerces-perl package into the
XML::Xerces namespace even though the "-package" option in SWIG 1.1 is
broken.
I'll send you the changes ASAP (the only reason I did this was to see if
it could be
done, and because SWIG 1.3 is still alpha).
A few more things:
Since the InputSources that come with Xerces are all working under
xerces-perl,
we can drop the non-standard ones I built early-on in the project.
These are
FileInputSource and MemoryInputSource.
The standard InputSource's that come with Xerces, i.e. LocalFileInputSource,
StdInInputSource, and MemBufInputSource provide essentially the same
functionality.
The only thing FileInputSource allows over and above these is the
ability to take an
XML document through an arbitrary file-descriptor, which is unlikely
ever to be needed.
If it does, we could create a "DescriptorInputSource."
So, if we're in agreement, I'd like to scrap FileInputSource and
MemoryInputSource.
Also, scrapping FileInputSource would render the Xerces.C.diff file
unnecessary.
That would eliminate a headache.
-- Harmon
Jason E. Stewart wrote:
> "Harmon S. Nine" <hn...@netarx.com> writes:
>
>
>> In a marathon session, I was able to work out all the kinks in xerces-perl
>> to get it to work with XWIG 1.3. Everything compiles. All the tests work.
>>
>> I'll be shipping it to Jason and everyone on the list sometime between
>> tomorrow and
>> Monday.
>
> Harmon sent me his patches, and I have now checked them in to the
> Rel-1_3-SWIG-1_3 branch for testing.
>
> The big news:
> * namespace is now XML::Xerces
> * RTTI.pm moved to XML::Xerces::RTTI to be consistent
> * SWIG 1.3 is required
> * It all works!!! (thanks Harmon)
>
> I've started munging the test scripts a bit, to make them more
> consistent with other modules, I'll continue with this. Right now you
> get the ugly "unitialized value in global destructor" warning, but
> I'll fix that, it's just a warning...
>
> TODO:
> * Merge the SWIG 1.3 into the main branch
> * Cut a new release
> * update the WWW pages
> * Announce this to the World!!!!
> * Celebrate!!!!!!!!
>
> Cheers,
> jas.
>
> PS. Harmon would you update from CVS to get this version and make sure
> everything is still kosher for your installation?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Harmon S. Nine" <hn...@netarx.com> writes:
> In a marathon session, I was able to work out all the kinks in xerces-perl
> to get it to work with XWIG 1.3. Everything compiles. All the tests work.
>
> I'll be shipping it to Jason and everyone on the list sometime between
> tomorrow and
> Monday.
Harmon sent me his patches, and I have now checked them in to the
Rel-1_3-SWIG-1_3 branch for testing.
The big news:
* namespace is now XML::Xerces
* RTTI.pm moved to XML::Xerces::RTTI to be consistent
* SWIG 1.3 is required
* It all works!!! (thanks Harmon)
I've started munging the test scripts a bit, to make them more
consistent with other modules, I'll continue with this. Right now you
get the ugly "unitialized value in global destructor" warning, but
I'll fix that, it's just a warning...
TODO:
* Merge the SWIG 1.3 into the main branch
* Cut a new release
* update the WWW pages
* Announce this to the World!!!!
* Celebrate!!!!!!!!
Cheers,
jas.
PS. Harmon would you update from CVS to get this version and make sure
everything is still kosher for your installation?
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Good news! SWIG 1.3 and xerces-perl are playing nice together
Posted by "Harmon S. Nine" <hn...@netarx.com>.
Hello all.
In a marathon session, I was able to work out all the kinks in xerces-perl
to get it to work with XWIG 1.3. Everything compiles. All the tests work.
I'll be shipping it to Jason and everyone on the list sometime between
tomorrow and
Monday.
Cheers.
-- Harmon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Perl samples
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
"Juan Leon" <jl...@cs.cmu.edu> writes:
> The C++ API docs show several DOMParser constructors.
> One of them takes an XMLCh *, another takes a char *. I spent
> some time reading the swig docs, and XERCES.i, and I still didn't
> understand how swig picked a particular constructor to bind to
> Perl's "new" "method". It doesn't matter much, if I can get it
> to work. It's just that FileInputSource wasn't working either,
> at the time. Now I have another problem that I am trying
> to distill for everyone's "enjoyment". Watch this space.
Among the really nice things that Harmon did with the Perl API, was
that anyplace that the C++ API wants a XMLCh* or a DOMString*, in perl
you can just use a regular old perl-string, and it will get converted
for you, behind the scenes. Also, any function that returns one of
those in the C++ API will instead return a perl-string.
> > Where is DOMCount.pl mentioned? The tests in the 't' directory provide
> > some pretty good examples of how to parse documents using the
> > inputsources, as well as how to build a DOM from scratch (domTest.t)
> >
>
> Yes, Jason Stewart pointed me to "t". That got me further. Thanks!
> DOMCount.pl is mentioned in several places, one of them is
> http://xml.apache.org/xerces-p/samples.html.
DOMCount.pl is one of standard test programs that are included in the
C++ API, and Tom Watson included them in his original Windows port. If
you check out the current CVS code, you will see Tom's old scripts in
the samples/ directory. They are currently broken, and need to be
ported to the new API.
jas.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Perl samples
Posted by "Harmon S. Nine" <hn...@netarx.com>.
Juan:
Juan Leon wrote:
> The C++ API docs show several DOMParser constructors.
> One of them takes an XMLCh *, another takes a char *. I spent
> some time reading the swig docs, and XERCES.i, and I still didn't
> understand how swig picked a particular constructor to bind to
> Perl's "new" "method". It doesn't matter much, if I can get it
> to work. It's just that FileInputSource wasn't working either,
> at the time. Now I have another problem that I am trying
> to distill for everyone's "enjoyment". Watch this space.
>
Actually, since SWIG doesn't support function overloading, for each set of
overloaded functions, I just kinda' picked the instance that would
(hopefully) be
wrappered the easiest. All other instances were commented out :-)
-- Harmon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Perl samples
Posted by Juan Leon <jl...@cs.cmu.edu>.
Harmon, First, thank you very much for the tarball, and for
the continued assistance. Thanks also to Jason Stewart for
his kind message pointing me to the "t" subdir.
--On Thursday, March 08, 2001 9:24 AM -0500 "Harmon S. Nine"
<hn...@netarx.com> wrote:
>> [Lots of interesting stuff...]
>>
>> so I am having some trouble. An example: how
>> do I call DOMParser::parse with a file name as argument? Looks like
>> the perl binding is to the constructor that takes an InputSource rather
>> than a string, but when I try to use FileInputSource in erl I get a core
>> dump.
>
> Yes. A DOMParser takes an inputsource instead of a string, see API docs
> at xml.apache.org for details.
>
The C++ API docs show several DOMParser constructors.
One of them takes an XMLCh *, another takes a char *. I spent
some time reading the swig docs, and XERCES.i, and I still didn't
understand how swig picked a particular constructor to bind to
Perl's "new" "method". It doesn't matter much, if I can get it
to work. It's just that FileInputSource wasn't working either,
at the time. Now I have another problem that I am trying
to distill for everyone's "enjoyment". Watch this space.
>> Anyway, I figure this and other questions I have would be answered
>> with the
>> sample DOMCount.pl which I have seen mentioned but which I have not
>> found
>> anywhere. Is there such a sample. Another one that would help me?
>
> Where is DOMCount.pl mentioned? The tests in the 't' directory provide
> some pretty good examples of how to parse documents using the
> inputsources, as well as how to build a DOM from scratch (domTest.t)
>
Yes, Jason Stewart pointed me to "t". That got me further. Thanks!
DOMCount.pl is mentioned in several places, one of them is
http://xml.apache.org/xerces-p/samples.html.
Thanks again,
Juan
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
Re: Perl samples
Posted by "Harmon S. Nine" <hn...@netarx.com>.
Juan:
Juan Leon wrote:
> I got a xerces perl tarball from hnine@netarx.com. I am trying to
> use it
> by looking at the Xerces C++ API docs and pretty much guessing how to
> call the perl wrappers. I am a swig neophyte and I don't quite
> understand
> how the bindings work
In general, you call a perl-function generated by SWIG in the same way you'd
call it from "C", with some syntactic differences. For instance, to use
DOMParser::parse,
do the following:
$parser = new DOMParser;
$inputsource = new LocalFileInputSource('foo.xml');
$parser->parse( $inputsource);
Note here, the use of the LocalFileInputSource instead of
FileInputSource. When I first
started working on xerces-perl, when 1.1 was the latest version, I had a
hard time getting
any of the standard inputsources that came with the xerces distribution
to work through
perl. So I created by own, i.e. FileInputSource and MemoryInputSource.
There are now standard inputsources with the xerces distribution that
work in xerces-perl
and essentially do what FileInputSource and MemoryInputSource do. They
are called
LocalFileInputSource and MemBufInputSource. The use of these is
preferred over the
former, since they are standard.
Note:
MembufInputSource, where in xerces-C takes four arguments, in
xerces-perl takes
2 arguments: a string variable containing an xml document, and a string
that is a
"pseudo-system-id". See API docs for a description of this argument.
> so I am having some trouble. An example: how
> do I call DOMParser::parse with a file name as argument? Looks like
> the perl binding is to the constructor that takes an InputSource rather
> than a string, but when I try to use FileInputSource in erl I get a core
> dump.
Yes. A DOMParser takes an inputsource instead of a string, see API docs
at xml.apache.org
for details.
> Anyway, I figure this and other questions I have would be answered
> with the
> sample DOMCount.pl which I have seen mentioned but which I have not
> found
> anywhere. Is there such a sample. Another one that would help me?
Where is DOMCount.pl mentioned? The tests in the 't' directory provide some
pretty good examples of how to parse documents using the inputsources,
as well
as how to build a DOM from scratch (domTest.t)
>
> Thank you. Please also let me know if there is a mailing list in which
> questions
> like this would be more appropriate.
This is the place :-)
> Juan Leon
> jl+@cs.cmu.edu
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-p-dev-help@xml.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-p-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-p-dev-help@xml.apache.org