Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in
To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #381778] Fri, 18 January 2008 20:14 Go to next message
Eclipse User
Originally posted by: rmishra.tibco.com

Hi ,
org.eclipse.emf.ecore.xmi plug-in uses
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
parsing purpose by default .

i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
i need to include xerces plug-in as a dependent plug-in of
org.eclipse.emf.ecore.xmi .So is there any way to do that .

org.eclipse.emf.ecore.xmi has a different class loader to load dependency
,so it doesn't recognizes the Xerces plug-in loded by any other class
loader.

Please help me out with this if can be can be done...
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #381779 is a reply to message #381778] Sat, 19 January 2008 08:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000602070401090806020408
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Raju,

Please use the EMF newsgroup for questions about EMF. I've added it to
the "to" list of the reply.


Raju Mishra wrote:
> Hi ,
> org.eclipse.emf.ecore.xmi plug-in uses
> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
> parsing purpose by default .
>
Actually, it doesn't. It uses JAXP APIs that use whatever the default
in for the JVM.
> i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
> i need to include xerces plug-in as a dependent plug-in of
> org.eclipse.emf.ecore.xmi .So is there any way to do that .
>
Well you obviously can't change the XMI plugin that everyone shares.
Perhaps if we addressed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827 it would be easier
for you, but it's not likely we can make such changes without breaking
existing clients.

> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
> ,so it doesn't recognizes the Xerces plug-in loded by any other class
> loader.
>
I wonder why you even care what implementation is used to provide the
SAX support?
> Please help me out with this if can be can be done...
>
If you used this load option

/**
* Specify a parser pool to be used for loading XML documents from
InputStream.
* You need to provide a XMLParserPool as the value of this option.
* <p>
* This option can dramatically improve performance for
deserialization (loading) of XML resource.
* </p>
* @see org.eclipse.emf.ecore.xmi.XMLParserPool
*/
String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";

and specialized this method in your own derived XMLParserPoolImpl
implementation:

protected SAXParser makeParser(Map<String, Boolean> features,
Map<String, ?> properties) throws ParserConfigurationException,
SAXException
{
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();

// set parser features and properties
if (features != null)
{
for (String feature : features.keySet())
{
parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());
}
}
if (properties != null)
{
for (String property : properties.keySet())
{
parser.getXMLReader().setProperty(property,
properties.get(property));
}
}
return parser;
}

You could control which implementation gets created. I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that. Maybe some googling will turn
up an answer to that...
>
>
>
>


--------------000602070401090806020408
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Raju,<br>
<br>
Please use the EMF newsgroup for questions about EMF.&nbsp; I've added it to
the "to" list of the reply.<br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
parsing purpose by default .
</pre>
</blockquote>
Actually, it doesn't.&nbsp; It uses JAXP APIs that use whatever the default
in for the JVM.<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
i need to include xerces plug-in as a dependent plug-in of
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</pre>
</blockquote>
Well you obviously can't change the XMI plugin that everyone shares.&nbsp;
Perhaps if we addressed <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827">https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827</a>
it would be easier for you, but it's not likely we can make such
changes without breaking existing clients.<br>
<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
org.eclipse.emf.ecore.xmi has a different class loader to load dependency
,so it doesn't recognizes the Xerces plug-in loded by any other class
loader.
</pre>
</blockquote>
I wonder why you even care what implementation is used to provide the
SAX support? <br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
Please help me out with this if can be can be done...
</pre>
</blockquote>
If you used this load option<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Specify a parser pool to be used for loading XML
documents from InputStream.</small><br>
<small>&nbsp;&nbsp; * You need to provide a XMLParserPool as the value of this
option.</small><br>
<small>&nbsp;&nbsp; * &lt;p&gt;</small><br>
<small>&nbsp;&nbsp; * This option can dramatically improve performance for
deserialization (loading) of XML resource.</small><br>
<small>&nbsp;&nbsp; * &lt;/p&gt;</small><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.XMLParserPool</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";</small><br>
</blockquote>
and specialized this method in your own derived XMLParserPoolImpl
implementation:<br>
<blockquote><small>&nbsp; protected SAXParser makeParser(Map&lt;String,
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws
ParserConfigurationException, SAXException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; SAXParserFactory factory = SAXParserFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; factory.setValidating(false);<br>
&nbsp;&nbsp;&nbsp; factory.setNamespaceAware(true);<br>
&nbsp;&nbsp;&nbsp; SAXParser parser = factory.newSAXParser();<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; // set parser features and properties<br>
&nbsp;&nbsp;&nbsp; if (features != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String feature :&nbsp; features.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; if (properties != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String property : properties.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setProperty(property,
properties.get(property));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return parser;<br>
&nbsp; }</small><br>
</blockquote>
You could control which implementation gets created.&nbsp; I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that.&nbsp; Maybe some googling will turn
up an answer to that...<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">



</pre>
</blockquote>
<br>
</body>
</html>

--------------000602070401090806020408--
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #381780 is a reply to message #381779] Mon, 21 January 2008 20:54 Go to previous messageGo to next message
Eclipse User
Originally posted by: rmishra.tibco.com

This is a multi-part message in MIME format.

------=_NextPart_000_004C_01C85C56.A8ED3580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi ,
in my application ,in one of the jars the system property for setting =
parser factory implementation is set to apache's SAX Parser factory =
implementaion which is there in Xerces.jar and that doesn't come with =
JRE libs .
that's the reason i need XMI plug-in to load Xerces library . One way is =
that i can put it inside ext folder of JRE so that Boot Strap class =
loader loades it and can be found by every body . But i don't think it's =
a good way .=20
i did some googling and found out that i can create a plug-in fragment =
for XMI plug-in and there i can specify xerces as dependent jars ...

Thanks for helping me out --and let me know if there is any issue with =
plug-in fragment approach ---
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fmsu1v$eg0$1@build.eclipse.org...
Raju,

Please use the EMF newsgroup for questions about EMF. I've added it =
to the "to" list of the reply.


Raju Mishra wrote:=20
Hi ,
org.eclipse.emf.ecore.xmi plug-in uses=20
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for=20
parsing purpose by default .
Actually, it doesn't. It uses JAXP APIs that use whatever the default =
in for the JVM.

i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for =
that=20
i need to include xerces plug-in as a dependent plug-in of=20
org.eclipse.emf.ecore.xmi .So is there any way to do that .
Well you obviously can't change the XMI plugin that everyone shares. =
Perhaps if we addressed =
https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D212827 it would be =
easier for you, but it's not likely we can make such changes without =
breaking existing clients.


org.eclipse.emf.ecore.xmi has a different class loader to load =
dependency=20
,so it doesn't recognizes the Xerces plug-in loded by any other class=20
loader.
I wonder why you even care what implementation is used to provide the =
SAX support?=20

Please help me out with this if can be can be done...
If you used this load option

/**
* Specify a parser pool to be used for loading XML documents from =
InputStream.
* You need to provide a XMLParserPool as the value of this =
option.
* <p>
* This option can dramatically improve performance for =
deserialization (loading) of XML resource.
* </p>
* @see org.eclipse.emf.ecore.xmi.XMLParserPool
*/
String OPTION_USE_PARSER_POOL =3D "USE_PARSER_POOL";

and specialized this method in your own derived XMLParserPoolImpl =
implementation:

protected SAXParser makeParser(Map<String, Boolean> features, =
Map<String, ?> properties) throws ParserConfigurationException, =
SAXException
{
SAXParserFactory factory =3D SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
SAXParser parser =3D factory.newSAXParser();
=20
// set parser features and properties
if (features !=3D null)
{
for (String feature : features.keySet())
{
parser.getXMLReader().setFeature(feature, =
features.get(feature).booleanValue());
}
}
if (properties !=3D null)
{
for (String property : properties.keySet())
{
parser.getXMLReader().setProperty(property, =
properties.get(property));
}
}
return parser;
}

You could control which implementation gets created. I think there is =
also some way of directly influencing which implementation is used by =
the JAXP APIs, but I've never done that. Maybe some googling will turn =
up an answer to that...




=20

------=_NextPart_000_004C_01C85C56.A8ED3580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3157" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV>
<DIV><FONT face=3DArial size=3D2>Hi ,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>in my application ,in one of the jars =
the system=20
property for setting parser factory implementation is set to apache's =
SAX Parser=20
factory implementaion&nbsp; which is there in Xerces.jar and that =
doesn't come=20
with JRE libs .</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>that's the reason i need XMI plug-in to =
load Xerces=20
library . One way is that i can put it inside ext folder of JRE so that =
Boot=20
Strap class loader loades it and can be found by every body . But i =
don't think=20
it's a good way . </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i did some googling and found out that =
i can create=20
a plug-in fragment for XMI plug-in and there i can specify xerces as =
dependent=20
jars ...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for helping me out --and let me =
know if=20
there is any issue with plug-in fragment approach ---</FONT></DIV></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fmsu1v$eg0$1@build.eclipse.org">news:fmsu1v$eg0$1@build.ecli=
pse.org</A>...</DIV>Raju,<BR><BR>Please=20
use the EMF newsgroup for questions about EMF.&nbsp; I've added it to =
the "to"=20
list of the reply.<BR><BR><BR>Raju Mishra wrote:=20
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses=20
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for=20
parsing purpose by default .
</PRE></BLOCKQUOTE>Actually, it doesn't.&nbsp; It uses JAXP APIs that =
use=20
whatever the default in for the JVM.<BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">i want it to use =
org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that=20
i need to include xerces plug-in as a dependent plug-in of=20
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</PRE></BLOCKQUOTE>Well you obviously can't change the XMI plugin that =

everyone shares.&nbsp; Perhaps if we addressed <A=20
=
href=3D"https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D212827">https://b=
ugs.eclipse.org/bugs/show_bug.cgi?id=3D212827</A>=20
it would be easier for you, but it's not likely we can make such =
changes=20
without breaking existing clients.<BR><BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D""> org.eclipse.emf.ecore.xmi has a =
different class loader to load dependency=20
,so it doesn't recognizes the Xerces plug-in loded by any other class=20
loader.
</PRE></BLOCKQUOTE>I wonder why you even care what implementation is =
used to=20
provide the SAX support? <BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Please help me out with this if can be can =
be done...
</PRE></BLOCKQUOTE>If you used this load option<SMALL><BR></SMALL>
<BLOCKQUOTE><SMALL>&nbsp; /**</SMALL><BR><SMALL>&nbsp;&nbsp; * Specify =
a=20
parser pool to be used for loading XML documents from=20
InputStream.</SMALL><BR><SMALL>&nbsp;&nbsp; * You need to provide a=20
XMLParserPool as the value of this =
option.</SMALL><BR><SMALL>&nbsp;&nbsp; *=20
&lt;p&gt;</SMALL><BR><SMALL>&nbsp;&nbsp; * This option can =
dramatically=20
improve performance for deserialization (loading) of XML=20
resource.</SMALL><BR><SMALL>&nbsp;&nbsp; *=20
&lt;/p&gt;</SMALL><BR><SMALL>&nbsp;&nbsp; * @see=20
=
org.eclipse.emf.ecore.xmi.XMLParserPool</SMALL><BR><SMALL >&nbsp;&nbsp;=20
*/</SMALL><BR><SMALL>&nbsp; String OPTION_USE_PARSER_POOL =3D=20
"USE_PARSER_POOL";</SMALL><BR></BLOCKQUOTE>and specialized this =
method in your=20
own derived XMLParserPoolImpl implementation:<BR>
<BLOCKQUOTE><SMALL>&nbsp; protected SAXParser =
makeParser(Map&lt;String,=20
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws=20
ParserConfigurationException, SAXException<BR>&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
SAXParserFactory factory =3D=20
SAXParserFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp;=20
factory.setValidating(false);<BR>&nbsp;&nbsp;&nbsp;=20
factory.setNamespaceAware(true);<BR>&nbsp;&nbsp;&nbsp; SAXParser =
parser =3D=20
factory.newSAXParser();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; =
// set=20
parser features and properties<BR>&nbsp;&nbsp;&nbsp; if (features =
!=3D=20
null)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for =
(String=20
feature :&nbsp; features.keySet())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
parser.getXMLReader().setFeature(feature,=20
=
features.get(feature).booleanValue());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; if (properties !=3D=20
null)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for =
(String=20
property : properties.keySet())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
parser.getXMLReader().setProperty(property,=20
properties.get(property));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return =
parser;<BR>&nbsp;=20
}</SMALL><BR></BLOCKQUOTE>You could control which implementation =
gets=20
created.&nbsp; I think there is also some way of directly influencing =
which=20
implementation is used by the JAXP APIs, but I've never done =
that.&nbsp; Maybe=20
some googling will turn up an answer to that...<BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_004C_01C85C56.A8ED3580--
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #381781 is a reply to message #381780] Tue, 22 January 2008 06:43 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010702010501030009010803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Raju,

I've never used plugin fragments. Does the approach of creating the
parser yourself using the pool option not do the trick? Using a pool is
generally a good thing anyway for performance because SAX parsers are
obscenely expensive to create given the innocent looking line of code
that does it. For small instances, parser creation becomes a dominating
cost. It's still not clear why the implementation of the SAX parser is
important to control; is something not working unless you can control it?


Raju Mishra wrote:
> Hi ,
> in my application ,in one of the jars the system property for setting
> parser factory implementation is set to apache's SAX Parser factory
> implementaion which is there in Xerces.jar and that doesn't come with
> JRE libs .
> that's the reason i need XMI plug-in to load Xerces library . One way
> is that i can put it inside ext folder of JRE so that Boot Strap class
> loader loades it and can be found by every body . But i don't think
> it's a good way .
> i did some googling and found out that i can create a plug-in fragment
> for XMI plug-in and there i can specify xerces as dependent jars ...
>
> Thanks for helping me out --and let me know if there is any issue with
> plug-in fragment approach ---
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fmsu1v$eg0$1@build.eclipse.org...
> Raju,
>
> Please use the EMF newsgroup for questions about EMF. I've added
> it to the "to" list of the reply.
>
>
> Raju Mishra wrote:
>> Hi ,
>> org.eclipse.emf.ecore.xmi plug-in uses
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
>> parsing purpose by default .
>>
> Actually, it doesn't. It uses JAXP APIs that use whatever the
> default in for the JVM.
>> i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
>> i need to include xerces plug-in as a dependent plug-in of
>> org.eclipse.emf.ecore.xmi .So is there any way to do that .
>>
> Well you obviously can't change the XMI plugin that everyone
> shares. Perhaps if we addressed
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827 it would be
> easier for you, but it's not likely we can make such changes
> without breaking existing clients.
>
>> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
>> ,so it doesn't recognizes the Xerces plug-in loded by any other class
>> loader.
>>
> I wonder why you even care what implementation is used to provide
> the SAX support?
>> Please help me out with this if can be can be done...
>>
> If you used this load option
>
> /**
> * Specify a parser pool to be used for loading XML
> documents from InputStream.
> * You need to provide a XMLParserPool as the value of this
> option.
> * <p>
> * This option can dramatically improve performance for
> deserialization (loading) of XML resource.
> * </p>
> * @see org.eclipse.emf.ecore.xmi.XMLParserPool
> */
> String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";
>
> and specialized this method in your own derived XMLParserPoolImpl
> implementation:
>
> protected SAXParser makeParser(Map<String, Boolean>
> features, Map<String, ?> properties) throws
> ParserConfigurationException, SAXException
> {
> SAXParserFactory factory = SAXParserFactory.newInstance();
> factory.setValidating(false);
> factory.setNamespaceAware(true);
> SAXParser parser = factory.newSAXParser();
>
> // set parser features and properties
> if (features != null)
> {
> for (String feature : features.keySet())
> {
> parser.getXMLReader().setFeature(feature,
> features.get(feature).booleanValue());
> }
> }
> if (properties != null)
> {
> for (String property : properties.keySet())
> {
> parser.getXMLReader().setProperty(property,
> properties.get(property));
> }
> }
> return parser;
> }
>
> You could control which implementation gets created. I think
> there is also some way of directly influencing which
> implementation is used by the JAXP APIs, but I've never done
> that. Maybe some googling will turn up an answer to that...
>>
>>
>


--------------010702010501030009010803
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Raju,<br>
<br>
I've never used plugin fragments.&nbsp; Does the approach of creating the
parser yourself using the pool option not do the trick? Using a pool is
generally a good thing anyway for performance because SAX parsers are
obscenely expensive to create given the innocent looking line of code
that does it.&nbsp; For small instances, parser creation becomes a
dominating cost.&nbsp; It's still not clear why the implementation of the
SAX parser is important to control; is something not working unless you
can control it? <br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fn3icf$csr$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3157" name="GENERATOR">
<style></style>
<div>
<div><font face="Arial" size="2">Hi ,</font></div>
<div><font face="Arial" size="2">in my application ,in one of the
jars the system property for setting parser factory implementation is
set to apache's SAX Parser factory implementaion&nbsp; which is there in
Xerces.jar and that doesn't come with JRE libs .</font></div>
<div><font face="Arial" size="2">that's the reason i need XMI plug-in
to load Xerces library . One way is that i can put it inside ext folder
of JRE so that Boot Strap class loader loades it and can be found by
every body . But i don't think it's a good way . </font></div>
<div><font face="Arial" size="2">i did some googling and found out
that i can create a plug-in fragment for XMI plug-in and there i can
specify xerces as dependent jars ...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for helping me out --and let
me know if there is any issue with plug-in fragment approach ---</font></div>
</div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:fmsu1v$eg0$1@build.eclipse.org">news:fmsu1v$eg0$1@build.eclipse.org</a>...</div>
Raju,<br>
<br>
Please use the EMF newsgroup for questions about EMF.&nbsp; I've added it to
the "to" list of the reply.<br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
parsing purpose by default .
</pre>
</blockquote>
Actually, it doesn't.&nbsp; It uses JAXP APIs that use whatever the default
in for the JVM.<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
i need to include xerces plug-in as a dependent plug-in of
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</pre>
</blockquote>
Well you obviously can't change the XMI plugin that everyone shares.&nbsp;
Perhaps if we addressed <a moz-do-not-send="true"
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827">https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827</a>
it would be easier for you, but it's not likely we can make such
changes without breaking existing clients.<br>
<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap=""> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
,so it doesn't recognizes the Xerces plug-in loded by any other class
loader.
</pre>
</blockquote>
I wonder why you even care what implementation is used to provide the
SAX support? <br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Please help me out with this if can be can be done...
</pre>
</blockquote>
If you used this load option<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Specify a parser pool to be used for loading XML
documents from InputStream.</small><br>
<small>&nbsp;&nbsp; * You need to provide a XMLParserPool as the value of
this option.</small><br>
<small>&nbsp;&nbsp; * &lt;p&gt;</small><br>
<small>&nbsp;&nbsp; * This option can dramatically improve performance for
deserialization (loading) of XML resource.</small><br>
<small>&nbsp;&nbsp; * &lt;/p&gt;</small><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.XMLParserPool</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";</small><br>
</blockquote>
and specialized this method in your own derived XMLParserPoolImpl
implementation:<br>
<blockquote><small>&nbsp; protected SAXParser makeParser(Map&lt;String,
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws
ParserConfigurationException, SAXException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; SAXParserFactory factory = SAXParserFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; factory.setValidating(false);<br>
&nbsp;&nbsp;&nbsp; factory.setNamespaceAware(true);<br>
&nbsp;&nbsp;&nbsp; SAXParser parser = factory.newSAXParser();<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; // set parser features and properties<br>
&nbsp;&nbsp;&nbsp; if (features != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String feature :&nbsp; features.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; if (properties != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String property : properties.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setProperty(property,
properties.get(property));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return parser;<br>
&nbsp; }</small><br>
</blockquote>
You could control which implementation gets created.&nbsp; I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that.&nbsp; Maybe some googling will turn
up an answer to that...<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------010702010501030009010803--
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #602472 is a reply to message #381778] Sat, 19 January 2008 08:30 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000602070401090806020408
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Raju,

Please use the EMF newsgroup for questions about EMF. I've added it to
the "to" list of the reply.


Raju Mishra wrote:
> Hi ,
> org.eclipse.emf.ecore.xmi plug-in uses
> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
> parsing purpose by default .
>
Actually, it doesn't. It uses JAXP APIs that use whatever the default
in for the JVM.
> i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
> i need to include xerces plug-in as a dependent plug-in of
> org.eclipse.emf.ecore.xmi .So is there any way to do that .
>
Well you obviously can't change the XMI plugin that everyone shares.
Perhaps if we addressed
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827 it would be easier
for you, but it's not likely we can make such changes without breaking
existing clients.

> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
> ,so it doesn't recognizes the Xerces plug-in loded by any other class
> loader.
>
I wonder why you even care what implementation is used to provide the
SAX support?
> Please help me out with this if can be can be done...
>
If you used this load option

/**
* Specify a parser pool to be used for loading XML documents from
InputStream.
* You need to provide a XMLParserPool as the value of this option.
* <p>
* This option can dramatically improve performance for
deserialization (loading) of XML resource.
* </p>
* @see org.eclipse.emf.ecore.xmi.XMLParserPool
*/
String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";

and specialized this method in your own derived XMLParserPoolImpl
implementation:

protected SAXParser makeParser(Map<String, Boolean> features,
Map<String, ?> properties) throws ParserConfigurationException,
SAXException
{
SAXParserFactory factory = SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
SAXParser parser = factory.newSAXParser();

// set parser features and properties
if (features != null)
{
for (String feature : features.keySet())
{
parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());
}
}
if (properties != null)
{
for (String property : properties.keySet())
{
parser.getXMLReader().setProperty(property,
properties.get(property));
}
}
return parser;
}

You could control which implementation gets created. I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that. Maybe some googling will turn
up an answer to that...
>
>
>
>


--------------000602070401090806020408
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Raju,<br>
<br>
Please use the EMF newsgroup for questions about EMF.&nbsp; I've added it to
the "to" list of the reply.<br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
parsing purpose by default .
</pre>
</blockquote>
Actually, it doesn't.&nbsp; It uses JAXP APIs that use whatever the default
in for the JVM.<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
i need to include xerces plug-in as a dependent plug-in of
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</pre>
</blockquote>
Well you obviously can't change the XMI plugin that everyone shares.&nbsp;
Perhaps if we addressed <a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827">https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827</a>
it would be easier for you, but it's not likely we can make such
changes without breaking existing clients.<br>
<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
org.eclipse.emf.ecore.xmi has a different class loader to load dependency
,so it doesn't recognizes the Xerces plug-in loded by any other class
loader.
</pre>
</blockquote>
I wonder why you even care what implementation is used to provide the
SAX support? <br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">
Please help me out with this if can be can be done...
</pre>
</blockquote>
If you used this load option<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Specify a parser pool to be used for loading XML
documents from InputStream.</small><br>
<small>&nbsp;&nbsp; * You need to provide a XMLParserPool as the value of this
option.</small><br>
<small>&nbsp;&nbsp; * &lt;p&gt;</small><br>
<small>&nbsp;&nbsp; * This option can dramatically improve performance for
deserialization (loading) of XML resource.</small><br>
<small>&nbsp;&nbsp; * &lt;/p&gt;</small><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.XMLParserPool</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";</small><br>
</blockquote>
and specialized this method in your own derived XMLParserPoolImpl
implementation:<br>
<blockquote><small>&nbsp; protected SAXParser makeParser(Map&lt;String,
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws
ParserConfigurationException, SAXException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; SAXParserFactory factory = SAXParserFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; factory.setValidating(false);<br>
&nbsp;&nbsp;&nbsp; factory.setNamespaceAware(true);<br>
&nbsp;&nbsp;&nbsp; SAXParser parser = factory.newSAXParser();<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; // set parser features and properties<br>
&nbsp;&nbsp;&nbsp; if (features != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String feature :&nbsp; features.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; if (properties != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String property : properties.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setProperty(property,
properties.get(property));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return parser;<br>
&nbsp; }</small><br>
</blockquote>
You could control which implementation gets created.&nbsp; I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that.&nbsp; Maybe some googling will turn
up an answer to that...<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">



</pre>
</blockquote>
<br>
</body>
</html>

--------------000602070401090806020408--
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #602479 is a reply to message #381779] Mon, 21 January 2008 20:54 Go to previous message
Eclipse User
Originally posted by: rmishra.tibco.com

This is a multi-part message in MIME format.

------=_NextPart_000_004C_01C85C56.A8ED3580
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi ,
in my application ,in one of the jars the system property for setting =
parser factory implementation is set to apache's SAX Parser factory =
implementaion which is there in Xerces.jar and that doesn't come with =
JRE libs .
that's the reason i need XMI plug-in to load Xerces library . One way is =
that i can put it inside ext folder of JRE so that Boot Strap class =
loader loades it and can be found by every body . But i don't think it's =
a good way .=20
i did some googling and found out that i can create a plug-in fragment =
for XMI plug-in and there i can specify xerces as dependent jars ...

Thanks for helping me out --and let me know if there is any issue with =
plug-in fragment approach ---
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:fmsu1v$eg0$1@build.eclipse.org...
Raju,

Please use the EMF newsgroup for questions about EMF. I've added it =
to the "to" list of the reply.


Raju Mishra wrote:=20
Hi ,
org.eclipse.emf.ecore.xmi plug-in uses=20
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for=20
parsing purpose by default .
Actually, it doesn't. It uses JAXP APIs that use whatever the default =
in for the JVM.

i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for =
that=20
i need to include xerces plug-in as a dependent plug-in of=20
org.eclipse.emf.ecore.xmi .So is there any way to do that .
Well you obviously can't change the XMI plugin that everyone shares. =
Perhaps if we addressed =
https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D212827 it would be =
easier for you, but it's not likely we can make such changes without =
breaking existing clients.


org.eclipse.emf.ecore.xmi has a different class loader to load =
dependency=20
,so it doesn't recognizes the Xerces plug-in loded by any other class=20
loader.
I wonder why you even care what implementation is used to provide the =
SAX support?=20

Please help me out with this if can be can be done...
If you used this load option

/**
* Specify a parser pool to be used for loading XML documents from =
InputStream.
* You need to provide a XMLParserPool as the value of this =
option.
* <p>
* This option can dramatically improve performance for =
deserialization (loading) of XML resource.
* </p>
* @see org.eclipse.emf.ecore.xmi.XMLParserPool
*/
String OPTION_USE_PARSER_POOL =3D "USE_PARSER_POOL";

and specialized this method in your own derived XMLParserPoolImpl =
implementation:

protected SAXParser makeParser(Map<String, Boolean> features, =
Map<String, ?> properties) throws ParserConfigurationException, =
SAXException
{
SAXParserFactory factory =3D SAXParserFactory.newInstance();
factory.setValidating(false);
factory.setNamespaceAware(true);
SAXParser parser =3D factory.newSAXParser();
=20
// set parser features and properties
if (features !=3D null)
{
for (String feature : features.keySet())
{
parser.getXMLReader().setFeature(feature, =
features.get(feature).booleanValue());
}
}
if (properties !=3D null)
{
for (String property : properties.keySet())
{
parser.getXMLReader().setProperty(property, =
properties.get(property));
}
}
return parser;
}

You could control which implementation gets created. I think there is =
also some way of directly influencing which implementation is used by =
the JAXP APIs, but I've never done that. Maybe some googling will turn =
up an answer to that...




=20

------=_NextPart_000_004C_01C85C56.A8ED3580
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.2900.3157" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV>
<DIV><FONT face=3DArial size=3D2>Hi ,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>in my application ,in one of the jars =
the system=20
property for setting parser factory implementation is set to apache's =
SAX Parser=20
factory implementaion&nbsp; which is there in Xerces.jar and that =
doesn't come=20
with JRE libs .</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>that's the reason i need XMI plug-in to =
load Xerces=20
library . One way is that i can put it inside ext folder of JRE so that =
Boot=20
Strap class loader loades it and can be found by every body . But i =
don't think=20
it's a good way . </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>i did some googling and found out that =
i can create=20
a plug-in fragment for XMI plug-in and there i can specify xerces as =
dependent=20
jars ...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks for helping me out --and let me =
know if=20
there is any issue with plug-in fragment approach ---</FONT></DIV></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ed Merks" &lt;<A =
href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:fmsu1v$eg0$1@build.eclipse.org">news:fmsu1v$eg0$1@build.ecli=
pse.org</A>...</DIV>Raju,<BR><BR>Please=20
use the EMF newsgroup for questions about EMF.&nbsp; I've added it to =
the "to"=20
list of the reply.<BR><BR><BR>Raju Mishra wrote:=20
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses=20
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for=20
parsing purpose by default .
</PRE></BLOCKQUOTE>Actually, it doesn't.&nbsp; It uses JAXP APIs that =
use=20
whatever the default in for the JVM.<BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">i want it to use =
org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that=20
i need to include xerces plug-in as a dependent plug-in of=20
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</PRE></BLOCKQUOTE>Well you obviously can't change the XMI plugin that =

everyone shares.&nbsp; Perhaps if we addressed <A=20
=
href=3D"https://bugs.eclipse.org/bugs/show_bug.cgi?id=3D212827">https://b=
ugs.eclipse.org/bugs/show_bug.cgi?id=3D212827</A>=20
it would be easier for you, but it's not likely we can make such =
changes=20
without breaking existing clients.<BR><BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D""> org.eclipse.emf.ecore.xmi has a =
different class loader to load dependency=20
,so it doesn't recognizes the Xerces plug-in loded by any other class=20
loader.
</PRE></BLOCKQUOTE>I wonder why you even care what implementation is =
used to=20
provide the SAX support? <BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">Please help me out with this if can be can =
be done...
</PRE></BLOCKQUOTE>If you used this load option<SMALL><BR></SMALL>
<BLOCKQUOTE><SMALL>&nbsp; /**</SMALL><BR><SMALL>&nbsp;&nbsp; * Specify =
a=20
parser pool to be used for loading XML documents from=20
InputStream.</SMALL><BR><SMALL>&nbsp;&nbsp; * You need to provide a=20
XMLParserPool as the value of this =
option.</SMALL><BR><SMALL>&nbsp;&nbsp; *=20
&lt;p&gt;</SMALL><BR><SMALL>&nbsp;&nbsp; * This option can =
dramatically=20
improve performance for deserialization (loading) of XML=20
resource.</SMALL><BR><SMALL>&nbsp;&nbsp; *=20
&lt;/p&gt;</SMALL><BR><SMALL>&nbsp;&nbsp; * @see=20
=
org.eclipse.emf.ecore.xmi.XMLParserPool</SMALL><BR><SMALL >&nbsp;&nbsp;=20
*/</SMALL><BR><SMALL>&nbsp; String OPTION_USE_PARSER_POOL =3D=20
"USE_PARSER_POOL";</SMALL><BR></BLOCKQUOTE>and specialized this =
method in your=20
own derived XMLParserPoolImpl implementation:<BR>
<BLOCKQUOTE><SMALL>&nbsp; protected SAXParser =
makeParser(Map&lt;String,=20
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws=20
ParserConfigurationException, SAXException<BR>&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
SAXParserFactory factory =3D=20
SAXParserFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp;=20
factory.setValidating(false);<BR>&nbsp;&nbsp;&nbsp;=20
factory.setNamespaceAware(true);<BR>&nbsp;&nbsp;&nbsp; SAXParser =
parser =3D=20
factory.newSAXParser();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; =
// set=20
parser features and properties<BR>&nbsp;&nbsp;&nbsp; if (features =
!=3D=20
null)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for =
(String=20
feature :&nbsp; features.keySet())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
parser.getXMLReader().setFeature(feature,=20
=
features.get(feature).booleanValue());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =

}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; if (properties !=3D=20
null)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for =
(String=20
property : properties.keySet())<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;=20
parser.getXMLReader().setProperty(property,=20
properties.get(property));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return =
parser;<BR>&nbsp;=20
}</SMALL><BR></BLOCKQUOTE>You could control which implementation =
gets=20
created.&nbsp; I think there is also some way of directly influencing =
which=20
implementation is used by the JAXP APIs, but I've never done =
that.&nbsp; Maybe=20
some googling will turn up an answer to that...<BR>
<BLOCKQUOTE cite=3Dmid:fmritu$62v$1@build.eclipse.org =
type=3D"cite"><PRE wrap=3D"">


</PRE></BLOCKQUOTE><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_004C_01C85C56.A8ED3580--
Re: To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in [message #602487 is a reply to message #381780] Tue, 22 January 2008 06:43 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25999
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010702010501030009010803
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Raju,

I've never used plugin fragments. Does the approach of creating the
parser yourself using the pool option not do the trick? Using a pool is
generally a good thing anyway for performance because SAX parsers are
obscenely expensive to create given the innocent looking line of code
that does it. For small instances, parser creation becomes a dominating
cost. It's still not clear why the implementation of the SAX parser is
important to control; is something not working unless you can control it?


Raju Mishra wrote:
> Hi ,
> in my application ,in one of the jars the system property for setting
> parser factory implementation is set to apache's SAX Parser factory
> implementaion which is there in Xerces.jar and that doesn't come with
> JRE libs .
> that's the reason i need XMI plug-in to load Xerces library . One way
> is that i can put it inside ext folder of JRE so that Boot Strap class
> loader loades it and can be found by every body . But i don't think
> it's a good way .
> i did some googling and found out that i can create a plug-in fragment
> for XMI plug-in and there i can specify xerces as dependent jars ...
>
> Thanks for helping me out --and let me know if there is any issue with
> plug-in fragment approach ---
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:fmsu1v$eg0$1@build.eclipse.org...
> Raju,
>
> Please use the EMF newsgroup for questions about EMF. I've added
> it to the "to" list of the reply.
>
>
> Raju Mishra wrote:
>> Hi ,
>> org.eclipse.emf.ecore.xmi plug-in uses
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
>> parsing purpose by default .
>>
> Actually, it doesn't. It uses JAXP APIs that use whatever the
> default in for the JVM.
>> i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
>> i need to include xerces plug-in as a dependent plug-in of
>> org.eclipse.emf.ecore.xmi .So is there any way to do that .
>>
> Well you obviously can't change the XMI plugin that everyone
> shares. Perhaps if we addressed
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827 it would be
> easier for you, but it's not likely we can make such changes
> without breaking existing clients.
>
>> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
>> ,so it doesn't recognizes the Xerces plug-in loded by any other class
>> loader.
>>
> I wonder why you even care what implementation is used to provide
> the SAX support?
>> Please help me out with this if can be can be done...
>>
> If you used this load option
>
> /**
> * Specify a parser pool to be used for loading XML
> documents from InputStream.
> * You need to provide a XMLParserPool as the value of this
> option.
> * <p>
> * This option can dramatically improve performance for
> deserialization (loading) of XML resource.
> * </p>
> * @see org.eclipse.emf.ecore.xmi.XMLParserPool
> */
> String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";
>
> and specialized this method in your own derived XMLParserPoolImpl
> implementation:
>
> protected SAXParser makeParser(Map<String, Boolean>
> features, Map<String, ?> properties) throws
> ParserConfigurationException, SAXException
> {
> SAXParserFactory factory = SAXParserFactory.newInstance();
> factory.setValidating(false);
> factory.setNamespaceAware(true);
> SAXParser parser = factory.newSAXParser();
>
> // set parser features and properties
> if (features != null)
> {
> for (String feature : features.keySet())
> {
> parser.getXMLReader().setFeature(feature,
> features.get(feature).booleanValue());
> }
> }
> if (properties != null)
> {
> for (String property : properties.keySet())
> {
> parser.getXMLReader().setProperty(property,
> properties.get(property));
> }
> }
> return parser;
> }
>
> You could control which implementation gets created. I think
> there is also some way of directly influencing which
> implementation is used by the JAXP APIs, but I've never done
> that. Maybe some googling will turn up an answer to that...
>>
>>
>


--------------010702010501030009010803
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Raju,<br>
<br>
I've never used plugin fragments.&nbsp; Does the approach of creating the
parser yourself using the pool option not do the trick? Using a pool is
generally a good thing anyway for performance because SAX parsers are
obscenely expensive to create given the innocent looking line of code
that does it.&nbsp; For small instances, parser creation becomes a
dominating cost.&nbsp; It's still not clear why the implementation of the
SAX parser is important to control; is something not working unless you
can control it? <br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fn3icf$csr$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.3157" name="GENERATOR">
<style></style>
<div>
<div><font face="Arial" size="2">Hi ,</font></div>
<div><font face="Arial" size="2">in my application ,in one of the
jars the system property for setting parser factory implementation is
set to apache's SAX Parser factory implementaion&nbsp; which is there in
Xerces.jar and that doesn't come with JRE libs .</font></div>
<div><font face="Arial" size="2">that's the reason i need XMI plug-in
to load Xerces library . One way is that i can put it inside ext folder
of JRE so that Boot Strap class loader loades it and can be found by
every body . But i don't think it's a good way . </font></div>
<div><font face="Arial" size="2">i did some googling and found out
that i can create a plug-in fragment for XMI plug-in and there i can
specify xerces as dependent jars ...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks for helping me out --and let
me know if there is any issue with plug-in fragment approach ---</font></div>
</div>
<blockquote
style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<div>"Ed Merks" &lt;<a moz-do-not-send="true"
href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt; wrote in
message <a moz-do-not-send="true"
href="news:fmsu1v$eg0$1@build.eclipse.org">news:fmsu1v$eg0$1@build.eclipse.org</a>...</div>
Raju,<br>
<br>
Please use the EMF newsgroup for questions about EMF.&nbsp; I've added it to
the "to" list of the reply.<br>
<br>
<br>
Raju Mishra wrote:
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Hi ,
org.eclipse.emf.ecore.xmi plug-in uses
com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl class for
parsing purpose by default .
</pre>
</blockquote>
Actually, it doesn't.&nbsp; It uses JAXP APIs that use whatever the default
in for the JVM.<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">i want it to use org.apache.xerces.jaxp.SAXParserFactoryImpl class ,for that
i need to include xerces plug-in as a dependent plug-in of
org.eclipse.emf.ecore.xmi .So is there any way to do that .
</pre>
</blockquote>
Well you obviously can't change the XMI plugin that everyone shares.&nbsp;
Perhaps if we addressed <a moz-do-not-send="true"
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827">https://bugs.eclipse.org/bugs/show_bug.cgi?id=212827</a>
it would be easier for you, but it's not likely we can make such
changes without breaking existing clients.<br>
<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap=""> org.eclipse.emf.ecore.xmi has a different class loader to load dependency
,so it doesn't recognizes the Xerces plug-in loded by any other class
loader.
</pre>
</blockquote>
I wonder why you even care what implementation is used to provide the
SAX support? <br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">Please help me out with this if can be can be done...
</pre>
</blockquote>
If you used this load option<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * Specify a parser pool to be used for loading XML
documents from InputStream.</small><br>
<small>&nbsp;&nbsp; * You need to provide a XMLParserPool as the value of
this option.</small><br>
<small>&nbsp;&nbsp; * &lt;p&gt;</small><br>
<small>&nbsp;&nbsp; * This option can dramatically improve performance for
deserialization (loading) of XML resource.</small><br>
<small>&nbsp;&nbsp; * &lt;/p&gt;</small><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.XMLParserPool</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_USE_PARSER_POOL = "USE_PARSER_POOL";</small><br>
</blockquote>
and specialized this method in your own derived XMLParserPoolImpl
implementation:<br>
<blockquote><small>&nbsp; protected SAXParser makeParser(Map&lt;String,
Boolean&gt; features, Map&lt;String, ?&gt; properties) throws
ParserConfigurationException, SAXException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; SAXParserFactory factory = SAXParserFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; factory.setValidating(false);<br>
&nbsp;&nbsp;&nbsp; factory.setNamespaceAware(true);<br>
&nbsp;&nbsp;&nbsp; SAXParser parser = factory.newSAXParser();<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; // set parser features and properties<br>
&nbsp;&nbsp;&nbsp; if (features != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String feature :&nbsp; features.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setFeature(feature,
features.get(feature).booleanValue());<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; if (properties != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String property : properties.keySet())<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; parser.getXMLReader().setProperty(property,
properties.get(property));<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return parser;<br>
&nbsp; }</small><br>
</blockquote>
You could control which implementation gets created.&nbsp; I think there is
also some way of directly influencing which implementation is used by
the JAXP APIs, but I've never done that.&nbsp; Maybe some googling will turn
up an answer to that...<br>
<blockquote cite="mid:fmritu$62v$1@build.eclipse.org" type="cite">
<pre wrap="">

</pre>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------010702010501030009010803--
Previous Topic:To make org.eclipse.emf.ecore.xmi plug-in to load Xerces plug-in
Next Topic:EMF - JPA ?
Goto Forum:
  


Current Time: Thu Aug 21 02:24:01 EDT 2014

Powered by FUDForum. Page generated in 0.01789 seconds