Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » XSD indent serialization using JDK 1.5
XSD indent serialization using JDK 1.5 [message #66431] Wed, 08 March 2006 19:42 Go to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
schema, it is serialized without any indentation. This seems to be due
entirely to the version of JDK used when running the application. Works
fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
there any magical settings for resource save that overcome this problem?
Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson
Re: XSD indent serialization using JDK 1.5 [message #66450 is a reply to message #66431] Wed, 08 March 2006 19:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------070202040502030102010001
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

We do the following:

public class DefaultJAXPConfiguration implements JAXPConfiguration
{
public Transformer createTransformer(String encoding) throws
TransformerException
{
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//

transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
"2");

transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"2");
if (encoding != null)
{
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save. If there's another magic property
value to add to the list, we can do that too. Please let me know how
you solve this...

(You'd think something like specifying the indentation would be trivial,
but apparently not. But then, you'd think determining the encoding of
an input stream would be pretty basic as well, but that took years to
get right.)



Dave Carlson wrote:

>When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
>schema, it is serialized without any indentation. This seems to be due
>entirely to the version of JDK used when running the application. Works
>fine with JDK 1.4.x.
>
>I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
>there any magical settings for resource save that overcome this problem?
>Suggested workaround to customize the resource impl for XSD model?
>
>Thanks,
> Dave Carlson
>
>
>
>


--------------070202040502030102010001
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">
Dave,<br>
<br>
We do the following:<br>
<blockquote><small>public class DefaultJAXPConfiguration implements
JAXPConfiguration<br>
{<br>
&nbsp; public Transformer createTransformer(String encoding) throws
TransformerException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; Transformer transformer = transformerFactory.newTransformer();<br>
<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
<br>
&nbsp;&nbsp;&nbsp; // Unless a width is set, there will be only line breaks but no
indentation.<br>
&nbsp;&nbsp;&nbsp; // The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp; // so we set them both.<br>
&nbsp;&nbsp;&nbsp; //<br>
&nbsp;&nbsp;&nbsp;
transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;
transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; if (encoding != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return transformer;<br>
&nbsp; }</small><br>
</blockquote>
So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save.&nbsp; If there's another magic property
value to add to the list, we can do that too.&nbsp; Please let me know how
you solve this...<br>
<br>
(You'd think something like specifying the indentation would be
trivial, but apparently not.&nbsp; But then, you'd think determining the
encoding of an input stream would be pretty basic as well, but that
took years to get right.)<br>
<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunc2u$2fe$1@utils.eclipse.org" type="cite">
<pre wrap="">When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
schema, it is serialized without any indentation. This seems to be due
entirely to the version of JDK used when running the application. Works
fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
there any magical settings for resource save that overcome this problem?
Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

--------------070202040502030102010001--
Re: XSD indent serialization using JDK 1.5 [message #66471 is a reply to message #66450] Wed, 08 March 2006 22:10 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C642C2.6304DEB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks, Ed. A bit of Googling found that this is a known bug in Sun's =
JDK:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446

Unfortunately, it's fixed in 5.0u6(b07) and the current release from Sun =
is 5.0u6(b05). Anyone know if/where I can download a newer build?

The workaround noted in this bug requires wrapping the output stream. =
Ed, is that possible to do easily with the XSD resource writer?

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:duncnk$70q$1@utils.eclipse.org...
Dave,

We do the following:

public class DefaultJAXPConfiguration implements JAXPConfiguration
{
public Transformer createTransformer(String encoding) throws =
TransformerException
{
TransformerFactory transformerFactory =3D =
TransformerFactory.newInstance();
Transformer transformer =3D transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no =
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//
=
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount=
", "2");
=
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount"=
, "2");
if (encoding !=3D null)
{
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG =
option to pass that in during save. If there's another magic property =
value to add to the list, we can do that too. Please let me know how =
you solve this...

(You'd think something like specifying the indentation would be =
trivial, but apparently not. But then, you'd think determining the =
encoding of an input stream would be pretty basic as well, but that took =
years to get right.)



Dave Carlson wrote:=20
When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a =

schema, it is serialized without any indentation. This seems to be due=20
entirely to the version of JDK used when running the application. Works =

fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. =
Are=20
there any magical settings for resource save that overcome this problem? =

Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


=20

------=_NextPart_000_000D_01C642C2.6304DEB0
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks, Ed.&nbsp; A bit of Googling =
found that this=20
is a known bug in Sun's JDK:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D" http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446">htt=
p://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446</A></FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Unfortunately, it's fixed in 5.0u6(b07) =
and the=20
current release from Sun is 5.0u6(b05).&nbsp; Anyone know if/where I can =

download a newer build?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The workaround noted in this bug =
requires wrapping=20
the output stream.&nbsp; Ed, is that possible to do easily with the XSD =
resource=20
writer?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></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:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>We=20
do the following:<BR>
<BLOCKQUOTE><SMALL>public class DefaultJAXPConfiguration implements=20
JAXPConfiguration<BR>{<BR>&nbsp; public Transformer =
createTransformer(String=20
encoding) throws TransformerException<BR>&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
TransformerFactory transformerFactory =3D=20
TransformerFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp; Transformer=20
transformer =3D =
transformerFactory.newTransformer();<BR><BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.INDENT,=20
"yes");<BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.METHOD,=20
"xml");<BR><BR>&nbsp;&nbsp;&nbsp; // Unless a width is set, there =
will be=20
only line breaks but no indentation.<BR>&nbsp;&nbsp;&nbsp; // The =
IBM JDK=20
and the Sun JDK don't agree on the property =
name,<BR>&nbsp;&nbsp;&nbsp; //=20
so we set them both.<BR>&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty("{<A class=3Dmoz-txt-link-freetext=20
=
href=3D"http://xml.apache.org/xalan">http://xml.apache.org/xalan</A>}inde=
nt-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<A=20
class=3Dmoz-txt-link-freetext=20
=
href=3D"http://xml.apache.org/xslt">http://xml.apache.org/xslt</A>}indent=
-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp; if (encoding !=3D =
null)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.ENCODING,=20
encoding);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return=20
transformer;<BR>&nbsp; }</SMALL><BR></BLOCKQUOTE>So you could =
override this=20
and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
during=20
save.&nbsp; If there's another magic property value to add to the =
list, we can=20
do that too.&nbsp; Please let me know how you solve =
this...<BR><BR>(You'd=20
think something like specifying the indentation would be trivial, but=20
apparently not.&nbsp; But then, you'd think determining the encoding =
of an=20
input stream would be pretty basic as well, but that took years to get =

right.)<BR><BR><BR><BR>Dave Carlson wrote:=20
<BLOCKQUOTE cite=3Dmiddunc2u$2fe$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">When you are using JDK 1.5 (a.k.a. 5.0) and =
programmatically construct a=20
schema, it is serialized without any indentation. This seems to be due=20
entirely to the version of JDK used when running the application. Works =

fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. =
Are=20
there any magical settings for resource save that overcome this problem? =

Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

------=_NextPart_000_000D_01C642C2.6304DEB0--
Re: XSD indent serialization using JDK 1.5 [message #66491 is a reply to message #66471] Wed, 08 March 2006 22:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000401040307080407030800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.


Dave Carlson wrote:

> Thanks, Ed. A bit of Googling found that this is a known bug in Sun's
> JDK:
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446
>
> Unfortunately, it's fixed in 5.0u6(b07) and the current release from
> Sun is 5.0u6(b05). Anyone know if/where I can download a newer build?
>
> The workaround noted in this bug requires wrapping the output stream.
> Ed, is that possible to do easily with the XSD resource writer?
>
> Dave
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:duncnk$70q$1@utils.eclipse.org...
> Dave,
>
> We do the following:
>
> public class DefaultJAXPConfiguration implements JAXPConfiguration
> {
> public Transformer createTransformer(String encoding) throws
> TransformerException
> {
> TransformerFactory transformerFactory =
> TransformerFactory.newInstance();
> Transformer transformer = transformerFactory.newTransformer();
>
> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> transformer.setOutputProperty(OutputKeys.METHOD, "xml");
>
> // Unless a width is set, there will be only line breaks
> but no indentation.
> // The IBM JDK and the Sun JDK don't agree on the property
> name,
> // so we set them both.
> //
>
> transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
> "2");
>
> transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
> "2");
> if (encoding != null)
> {
> transformer.setOutputProperty(OutputKeys.ENCODING,
> encoding);
> }
> return transformer;
> }
>
> So you could override this and use the
> XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during
> save. If there's another magic property value to add to the list,
> we can do that too. Please let me know how you solve this...
>
> (You'd think something like specifying the indentation would be
> trivial, but apparently not. But then, you'd think determining
> the encoding of an input stream would be pretty basic as well, but
> that took years to get right.)
>
>
>
> Dave Carlson wrote:
>
>>When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
>>schema, it is serialized without any indentation. This seems to be due
>>entirely to the version of JDK used when running the application. Works
>>fine with JDK 1.4.x.
>>
>>I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
>>there any magical settings for resource save that overcome this problem?
>>Suggested workaround to customize the resource impl for XSD model?
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
>>
>


--------------000401040307080407030800
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">
Dave,<br>
<br>
You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunko0$inp$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Thanks, Ed.&nbsp; A bit of Googling found
that this is a known bug in Sun's JDK:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><a
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446</a></font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Unfortunately, it's fixed in
5.0u6(b07) and the current release from Sun is 5.0u6(b05).&nbsp; Anyone know
if/where I can download a newer build?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">The workaround noted in this bug
requires wrapping the output stream.&nbsp; Ed, is that possible to do easily
with the XSD resource writer?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Dave</font></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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
We do the following:<br>
<blockquote><small>public class DefaultJAXPConfiguration implements
JAXPConfiguration<br>
{<br>
&nbsp; public Transformer createTransformer(String encoding) throws
TransformerException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; Transformer transformer = transformerFactory.newTransformer();<br>
<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
<br>
&nbsp;&nbsp;&nbsp; // Unless a width is set, there will be only line breaks but no
indentation.<br>
&nbsp;&nbsp;&nbsp; // The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp; // so we set them both.<br>
&nbsp;&nbsp;&nbsp; //<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; if (encoding != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return transformer;<br>
&nbsp; }</small><br>
</blockquote>
So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save.&nbsp; If there's another magic property
value to add to the list, we can do that too.&nbsp; Please let me know how
you solve this...<br>
<br>
(You'd think something like specifying the indentation would be
trivial, but apparently not.&nbsp; But then, you'd think determining the
encoding of an input stream would be pretty basic as well, but that
took years to get right.)<br>
<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunc2u$2fe$1@utils.eclipse.org" type="cite">
<pre wrap="">When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
schema, it is serialized without any indentation. This seems to be due
entirely to the version of JDK used when running the application. Works
fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
there any magical settings for resource save that overcome this problem?
Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

--------------000401040307080407030800--
Re: XSD indent serialization using JDK 1.5 [message #66512 is a reply to message #66491] Sat, 11 March 2006 18:40 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C64500.9EE01540
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Sorry to keep bugging you Ed, but one more question...

What is the best way to override a resource factory that is contributed =
by another plugin, in this case override the XSDResourceFactoryImpl? =
The default XSD factory is registered via extension point, as follows. =
If I add a similar exention point in my plugin for the same file =
extension but a different factory, how does EMF choose among the =
alternatives? I assume that I need to register my override factory via =
code in the plugin activator, which will (??) take priority over the =
default factory registered via extension point.

<extension point=3D"org.eclipse.emf.ecore.extension_parser">
<parser type=3D"xsd" =
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" />
</extension>

Thanks!
Dave

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:dunl77$mlr$1@utils.eclipse.org...
Dave,

You can use XSDResourceImpl.save(Writer, Map) so you can pass in a =
wrapped stream if necessary.



------=_NextPart_000_001C_01C64500.9EE01540
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Sorry to keep bugging you Ed, but one =
more=20
question...</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What is the best way to override a =
resource factory=20
that is contributed by another plugin, in this case override the=20
XSDResourceFactoryImpl?&nbsp; The default XSD factory is registered via=20
extension point, as follows.&nbsp; If I add a similar exention point in =
my=20
plugin for the same file extension but a different factory, how does EMF =
choose=20
among the alternatives?&nbsp; I assume that I need to register my =
override=20
factory via code in the plugin activator, which will (??) take priority =
over the=20
default factory registered via extension point.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;extension=20
point=3D"org.eclipse.emf.ecore.extension_parser"&gt;</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; &lt;parser type=3D"xsd"=20
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" /&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/extension&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Dave</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</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:dunl77$mlr$1@utils.eclipse.org">news:dunl77$mlr$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>You=20
can use XSDResourceImpl.save(Writer, Map) so you can pass in a wrapped =
stream=20
if necessary.<BR><BR><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_001C_01C64500.9EE01540--
Re: XSD indent serialization using JDK 1.5 [message #66535 is a reply to message #66450] Sat, 11 March 2006 20:31 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

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

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:duncnk$70q$1@utils.eclipse.org...

> So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG =
option to pass that in during save. If there's another magic property=20
> value to add to the list, we can do that too. Please let me know how =
you solve this...

Ed,=20
I have a solution working under JDK 5.0u6 (the current release from =
Sun). Two changes are necessary
- add the Xerces specific "indent-number" to the JAXP transformation =
factory
transformerFactory.setAttribute("indent-number", new Integer(2));

- use a Writer instead of an OutputStream

I had been using Resource.save(options), but that uses an outputstream. =
So I wrote a simple utility class with a static helper. I asked about =
overriding the XSDResourceFactoryImpl, but no longer need to do that. =
But still interested in the best practice for this.

My solution looks like this:

public class XSDResourceUtil {

public static void save(XSDSchema schema, URI fileURI, ResourceSet =
resourceSet)
throws IOException {
XSDResourceImpl resource =3D new XSDResourceImpl(fileURI);
resource.getContents().add(schema);
resourceSet.getResources().add(resource);

URIConverter uriConverter =3D resourceSet.getURIConverter();
OutputStream outputStream =3D =
uriConverter.createOutputStream(fileURI);
Writer writer =3D new OutputStreamWriter(outputStream, "utf-8");

Map options =3D new HashMap();
options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new =
XercesJAXPConfiguration());
try {
resource.save(writer, options);
} finally {
writer.close();
}
}


private static class XercesJAXPConfiguration extends =
DefaultJAXPConfiguration {

public XercesJAXPConfiguration() {
super();
}

public Transformer createTransformer(String encoding) throws =
TransformerException {
TransformerFactory transformerFactory =3D =
TransformerFactory.newInstance();
=20
// workaround for JDK 1.5.0u6 and before
transformerFactory.setAttribute("indent-number", new Integer(2));
=20
Transformer transformer =3D transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no =
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//
=
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount=
", "2");
=
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount"=
, "2");
if (encoding !=3D null) {
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

}
}

------=_NextPart_000_0035_01C64510.1EAFAA60
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>"Ed Merks" &lt;merks@ca.ibm.com&gt; =
wrote in=20
message news:duncnk$70q$1@utils.eclipse.org...<BR><BR>&gt; So you could =
override=20
this and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
during=20
save.&nbsp; If there's another magic property </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt; value to add to the list, we can =
do that=20
too.&nbsp; Please let me know how you solve this...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ed, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a solution working under JDK =
5.0u6 (the=20
current release from Sun).&nbsp; Two changes are necessary</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>- add the Xerces specific =
"indent-number" to=20
the&nbsp;JAXP transformation factory</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
transformerFactory.setAttribute("indent-number", new =
Integer(2));</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- use a Writer instead of an=20
OutputStream</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I had been using =
Resource.save(options), but that=20
uses an outputstream.&nbsp; So I wrote a simple utility class with a =
static=20
helper.&nbsp; I asked about overriding the XSDResourceFactoryImpl, but =
no longer=20
need to do that.&nbsp; But still interested in the best practice for=20
this.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My solution looks like =
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class XSDResourceUtil =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;public static void save(XSDSchema =
schema, URI=20
fileURI, ResourceSet resourceSet)<BR>&nbsp;&nbsp;&nbsp;throws =
IOException=20
{<BR>&nbsp;&nbsp;XSDResourceImpl resource =3D new=20
XSDResourceImpl(fileURI);<BR>&nbsp;&nbsp;resource.getContents().add(schem=
a);<BR> &nbsp;&nbsp;resourceSet.getResources().add(resource) ; </FONT></DIV>=

<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;URIConverter uriConverter =
=3D=20
resourceSet.getURIConverter();<BR>&nbsp;&nbsp;OutputStream outputStream =
=3D=20
uriConverter.createOutputStream(fileURI);<BR>&nbsp;<FONT=20
color=3D#ff0000>&nbsp;Writer writer =3D new =
OutputStreamWriter(outputStream,=20
"utf-8");</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;Map options =3D new=20
HashMap();<BR>&nbsp;&nbsp;<STRONG><FONT=20
color=3D#ff0000>options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new=20
XercesJAXPConfiguration());<BR></FONT></STRONG>&nbsp;&nbsp;try=20
{<BR>&nbsp;&nbsp;<FONT color=3D#ff0000>&nbsp;resource.save(writer,=20
options);<BR></FONT>&nbsp;&nbsp;} finally=20
{<BR>&nbsp;&nbsp;&nbsp;writer.close();<BR>&nbsp;&nbsp;} <BR>&nbsp;}</FONT>=
</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>&nbsp;private static class=20
XercesJAXPConfiguration extends DefaultJAXPConfiguration {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;public =
XercesJAXPConfiguration()=20
{<BR>&nbsp;&nbsp;&nbsp;super();<BR>&nbsp;&nbsp;} </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;public Transformer=20
createTransformer(String encoding) throws TransformerException=20
{<BR>&nbsp;&nbsp;&nbsp;TransformerFactory transformerFactory =3D=20
TransformerFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;<F=
ONT=20
color=3D#ff0000><STRONG>&nbsp;// workaround for JDK 1.5.0u6 and=20
before<BR> &nbsp;&nbsp;&nbsp;transformerFactory.setAttribut e( "indent-numbe=
r", new=20
Integer(2));<BR></STRONG></FONT>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;T=
ransformer=20
transformer =3D transformerFactory.newTransformer();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.INDEN=
T,=20
"yes");<BR> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.MET=
HOD,=20
"xml");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;// Unless a width is =
set, there=20
will be only line breaks but no indentation.<BR>&nbsp;&nbsp;&nbsp;// The =
IBM JDK=20
and the Sun JDK don't agree on the property =
name,<BR>&nbsp;&nbsp;&nbsp;// so we=20
set them=20
both.<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;transformer.setOutputP=
roperty("{http://xml.apache.org/xalan}indent-amount",=20
"2");<BR> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{http://xml.apa=
che.org/xslt}indent-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp;if (encoding !=3D null)=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;transformer.setOutpu tProperty(OutputKeys.ENC=
ODING,=20
encoding);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;return=20
transformer;<BR>&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;}<BR>}<BR></FONT></DIV></BODY></HTML >

------=_NextPart_000_0035_01C64510.1EAFAA60--
Re: XSD indent serialization using JDK 1.5 [message #66557 is a reply to message #66512] Mon, 13 March 2006 11:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------080006010504090300080909
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

There can only be one global registration, but you can make a local
registration in any ResourceSet via getResourceFactoryRegistry().


Dave Carlson wrote:

> Sorry to keep bugging you Ed, but one more question...
>
> What is the best way to override a resource factory that is
> contributed by another plugin, in this case override the
> XSDResourceFactoryImpl? The default XSD factory is registered via
> extension point, as follows. If I add a similar exention point in my
> plugin for the same file extension but a different factory, how does
> EMF choose among the alternatives? I assume that I need to register
> my override factory via code in the plugin activator, which will (??)
> take priority over the default factory registered via extension point.
>
> <extension point="org.eclipse.emf.ecore.extension_parser">
> <parser type="xsd"
> class="org.eclipse.xsd.util.XSDResourceFactoryImpl" />
> </extension>
>
> Thanks!
> Dave
>
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:dunl77$mlr$1@utils.eclipse.org...
> Dave,
>
> You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
> wrapped stream if necessary.
>
>


--------------080006010504090300080909
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">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dave,<br>
<br>
There can only be one global registration, but you can make a local
registration in any ResourceSet via getResourceFactoryRegistry().<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midduv5la$ijn$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Sorry to keep bugging you Ed, but
one more question...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">What is the best way to override a
resource factory that is contributed by another plugin, in this case
override the XSDResourceFactoryImpl?&nbsp; The default XSD factory is
registered via extension point, as follows.&nbsp; If I add a similar
exention point in my plugin for the same file extension but a different
factory, how does EMF choose among the alternatives?&nbsp; I assume that I
need to register my override factory via code in the plugin activator,
which will (??) take priority over the default factory registered via
extension point.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&lt;extension
point="org.eclipse.emf.ecore.extension_parser"&gt;</font ></div>
<div><font face="Arial" size="2">&nbsp;&nbsp; &lt;parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl" /&gt;</font></div>
<div><font face="Arial" size="2">&lt;/extension&gt;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks!</font></div>
<div><font face="Arial" size="2">&nbsp; Dave</font></div>
<div>&nbsp;</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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:dunl77$mlr$1@utils.eclipse.org">news:dunl77$mlr$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.<br>
<br>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080006010504090300080909--
Re: XSD indent serialization using JDK 1.5 [message #66578 is a reply to message #66535] Mon, 13 March 2006 12:16 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------080704090600050406070604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

XSDResourceImpl has this verison of save already:

public final void save(Writer writer, Map options) throws IOException

Wouldn't that work?


Dave Carlson wrote:

> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:duncnk$70q$1@utils.eclipse.org...
>
> > So you could override this and use the
> XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during save.
> If there's another magic property
> > value to add to the list, we can do that too. Please let me know
> how you solve this...
>
> Ed,
> I have a solution working under JDK 5.0u6 (the current release from
> Sun). Two changes are necessary
> - add the Xerces specific "indent-number" to the JAXP transformation
> factory
> transformerFactory.setAttribute("indent-number", new Integer(2));
>
> - use a Writer instead of an OutputStream
>
> I had been using Resource.save(options), but that uses an
> outputstream. So I wrote a simple utility class with a static
> helper. I asked about overriding the XSDResourceFactoryImpl, but no
> longer need to do that. But still interested in the best practice for
> this.
>
> My solution looks like this:
>
> public class XSDResourceUtil {
>
> public static void save(XSDSchema schema, URI fileURI, ResourceSet
> resourceSet)
> throws IOException {
> XSDResourceImpl resource = new XSDResourceImpl(fileURI);
> resource.getContents().add(schema);
> resourceSet.getResources().add(resource);
>
> URIConverter uriConverter = resourceSet.getURIConverter();
> OutputStream outputStream = uriConverter.createOutputStream(fileURI);
> Writer writer = new OutputStreamWriter(outputStream, "utf-8");
>
> Map options = new HashMap();
> *options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new
> XercesJAXPConfiguration());
> * try {
> resource.save(writer, options);
> } finally {
> writer.close();
> }
> }
>
>
> private static class XercesJAXPConfiguration extends
> DefaultJAXPConfiguration {
>
> public XercesJAXPConfiguration() {
> super();
> }
>
> public Transformer createTransformer(String encoding) throws
> TransformerException {
> TransformerFactory transformerFactory =
> TransformerFactory.newInstance();
>
> * // workaround for JDK 1.5.0u6 and before
> transformerFactory.setAttribute("indent-number", new Integer(2));
> *
> Transformer transformer = transformerFactory.newTransformer();
>
> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> transformer.setOutputProperty(OutputKeys.METHOD, "xml");
>
> // Unless a width is set, there will be only line breaks but no
> indentation.
> // The IBM JDK and the Sun JDK don't agree on the property name,
> // so we set them both.
> //
> transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
> "2");
> transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
> "2");
> if (encoding != null) {
> transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
> }
> return transformer;
> }
>
> }
> }



--------------080704090600050406070604
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">
Dave,<br>
<br>
XSDResourceImpl has this verison of save already:<br>
<br>
&nbsp; public final void save(Writer writer, Map options) throws IOException<br>
<br>
Wouldn't that work?<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midduvc5a$vlr$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a>
wrote in message <a class="moz-txt-link-freetext" href="news:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.eclipse.org</a>...<br>
<br>
&gt; So you could override this and use the
XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during save.&nbsp; If
there's another magic property </font></div>
<div><font face="Arial" size="2">&gt; value to add to the list, we
can do that too.&nbsp; Please let me know how you solve this...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Ed, </font></div>
<div><font face="Arial" size="2">I have a solution working under JDK
5.0u6 (the current release from Sun).&nbsp; Two changes are necessary</font></div>
<div><font face="Arial" size="2">- add the Xerces specific
"indent-number" to the&nbsp;JAXP transformation factory</font></div>
<div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp;
transformerFactory.setAttribute("indent-number", new Integer(2));</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">- use a Writer instead of an
OutputStream</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I had been using
Resource.save(options), but that uses an outputstream.&nbsp; So I wrote a
simple utility class with a static helper.&nbsp; I asked about overriding
the XSDResourceFactoryImpl, but no longer need to do that.&nbsp; But still
interested in the best practice for this.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">My solution looks like this:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">public class XSDResourceUtil {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;public static void save(XSDSchema
schema, URI fileURI, ResourceSet resourceSet)<br>
&nbsp;&nbsp;&nbsp;throws IOException {<br>
&nbsp;&nbsp;XSDResourceImpl resource = new XSDResourceImpl(fileURI);<br>
&nbsp;&nbsp;resource.getContents().add(schema);<br>
&nbsp;&nbsp;resourceSet.getResources().add(resource) ; </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;URIConverter uriConverter =
resourceSet.getURIConverter();<br>
&nbsp;&nbsp;OutputStream outputStream = uriConverter.createOutputStream(fileURI);<br>
&nbsp;<font color="#ff0000">&nbsp;Writer writer = new
OutputStreamWriter(outputStream, "utf-8");</font></font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;Map options = new HashMap();<br>
&nbsp;&nbsp;<strong><font color="#ff0000">options.put(XSDResourceImpl.XSD_JAXP_CONFIG,
new XercesJAXPConfiguration());<br>
</font></strong>&nbsp;&nbsp;try {<br>
&nbsp;&nbsp;<font color="#ff0000">&nbsp;resource.save(writer, options);<br>
</font>&nbsp;&nbsp;} finally {<br>
&nbsp;&nbsp;&nbsp;writer.close();<br>
&nbsp;&nbsp;}<br>
&nbsp;}</font></div>
<div>&nbsp;</div>
<div><br>
<font face="Arial" size="2">&nbsp;private static class
XercesJAXPConfiguration extends DefaultJAXPConfiguration {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;public XercesJAXPConfiguration() {<br>
&nbsp;&nbsp;&nbsp;super();<br>
&nbsp;&nbsp;}</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;public Transformer
createTransformer(String encoding) throws TransformerException {<br>
&nbsp;&nbsp;&nbsp;TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#ff0000"><strong>&nbsp;// workaround for JDK 1.5.0u6 and
before<br>
&nbsp;&nbsp;&nbsp;transformerFactory.setAttribut e( "indent-number", new Integer(2));<br>
</strong></font>&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;Transformer transformer = transformerFactory.newTransformer();</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.INDENT,
"yes");<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.METHOD, "xml");</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp;// Unless a width is set, there
will be only line breaks but no indentation.<br>
&nbsp;&nbsp;&nbsp;// The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp;// so we set them both.<br>
&nbsp;&nbsp;&nbsp;//<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;if (encoding != null) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;transformer.setOutpu tProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;return transformer;<br>
&nbsp;&nbsp;}</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;}<br>
}<br>
</font></div>
</blockquote>
<br>
</body>
</html>

--------------080704090600050406070604--
Re: XSD indent serialization using JDK 1.5 [message #66599 is a reply to message #66578] Mon, 13 March 2006 15:15 Go to previous messageGo to next message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C64676.3E79E920
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Yes, except that in my code it is usually most convenient to call:

resource.save(options);

This method uses the resource URI to write the file, but it always uses =
an OutputStream. I need to study exactly what the URIConverter does on =
the resource.save() implementation, and if it's necessary in my case. =
To use the save method that you list here, would I need to include the =
URIConverter code anyplace I wanted to save an XSD resource? =
Could/should the resource.save(options) implementation use Writer =
instead of OutputStream?

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:dv3nu0$efj$1@utils.eclipse.org...
Dave,

XSDResourceImpl has this verison of save already:

public final void save(Writer writer, Map options) throws =
IOException

Wouldn't that work?

------=_NextPart_000_000A_01C64676.3E79E920
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Yes, except that in my code it is =
usually most=20
convenient to call:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>resource.save(options);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This method uses the resource URI to =
write the=20
file, but it always uses an OutputStream.&nbsp; I need to study exactly =
what the=20
URIConverter does on the resource.save() implementation, and if it's =
necessary=20
in my case.&nbsp; To use the save method that you list here, would I =
need to=20
include the URIConverter code anyplace I wanted to save an XSD =
resource?&nbsp;=20
Could/should the resource.save(options) implementation use Writer =
instead of=20
OutputStream?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></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:dv3nu0$efj$1@utils.eclipse.org">news:dv3nu0$efj$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>XSDResourceImpl=20
has this verison of save already:<BR><BR>&nbsp; public final void =
save(Writer=20
writer, Map options) throws IOException<BR><BR>Wouldn't that=20
work?<BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000A_01C64676.3E79E920--
Re: XSD indent serialization using JDK 1.5 [message #66620 is a reply to message #66599] Mon, 13 March 2006 15:26 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------080106090600090702010904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

The URI converter simply opens a stream so if you want to open the
stream some other way, that's fine; or you can always call the URI
converter directly to open the stream. In EMF 2.2, we've introduced
URIConverter.ReadonableInputStream/WriteableOutputStream to allow a
wrapped reader or writer to be passed as an input or output stream using
the existing APIs (which we would not consider changing) and these may
be unwrapped by the resource implementation (as the resources in the XMI
plugin do) to access the reader or writer directly.


Dave Carlson wrote:

> Yes, except that in my code it is usually most convenient to call:
>
> resource.save(options);
>
> This method uses the resource URI to write the file, but it always
> uses an OutputStream. I need to study exactly what the URIConverter
> does on the resource.save() implementation, and if it's necessary in
> my case. To use the save method that you list here, would I need to
> include the URIConverter code anyplace I wanted to save an XSD
> resource? Could/should the resource.save(options) implementation use
> Writer instead of OutputStream?
>
> Dave
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:dv3nu0$efj$1@utils.eclipse.org...
> Dave,
>
> XSDResourceImpl has this verison of save already:
>
> public final void save(Writer writer, Map options) throws
> IOException
>
> Wouldn't that work?
>


--------------080106090600090702010904
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">
Dave,<br>
<br>
The URI converter simply opens a stream so if you want to open the
stream some other way, that's fine; or you can always call the URI
converter directly to open the stream.&nbsp; In EMF 2.2, we've introduced
URIConverter.ReadonableInputStream/WriteableOutputStream to allow a
wrapped reader or writer to be passed as an input or output stream
using the existing APIs (which we would not consider changing) and
these may be unwrapped by the resource implementation (as the resources
in the XMI plugin do) to access the reader or writer directly.<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middv42d7$qbt$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Yes, except that in my code it is
usually most convenient to call:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">resource.save(options);</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">This method uses the resource URI to
write the file, but it always uses an OutputStream.&nbsp; I need to study
exactly what the URIConverter does on the resource.save()
implementation, and if it's necessary in my case.&nbsp; To use the save
method that you list here, would I need to include the URIConverter
code anyplace I wanted to save an XSD resource?&nbsp; Could/should the
resource.save(options) implementation use Writer instead of
OutputStream?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Dave</font></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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:dv3nu0$efj$1@utils.eclipse.org">news:dv3nu0$efj$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
XSDResourceImpl has this verison of save already:<br>
<br>
&nbsp; public final void save(Writer writer, Map options) throws IOException<br>
<br>
Wouldn't that work?<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080106090600090702010904--
Re: XSD indent serialization using JDK 1.5 [message #597729 is a reply to message #66431] Wed, 08 March 2006 19:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070202040502030102010001
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

We do the following:

public class DefaultJAXPConfiguration implements JAXPConfiguration
{
public Transformer createTransformer(String encoding) throws
TransformerException
{
TransformerFactory transformerFactory =
TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//

transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
"2");

transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"2");
if (encoding != null)
{
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save. If there's another magic property
value to add to the list, we can do that too. Please let me know how
you solve this...

(You'd think something like specifying the indentation would be trivial,
but apparently not. But then, you'd think determining the encoding of
an input stream would be pretty basic as well, but that took years to
get right.)



Dave Carlson wrote:

>When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
>schema, it is serialized without any indentation. This seems to be due
>entirely to the version of JDK used when running the application. Works
>fine with JDK 1.4.x.
>
>I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
>there any magical settings for resource save that overcome this problem?
>Suggested workaround to customize the resource impl for XSD model?
>
>Thanks,
> Dave Carlson
>
>
>
>


--------------070202040502030102010001
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">
Dave,<br>
<br>
We do the following:<br>
<blockquote><small>public class DefaultJAXPConfiguration implements
JAXPConfiguration<br>
{<br>
&nbsp; public Transformer createTransformer(String encoding) throws
TransformerException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; Transformer transformer = transformerFactory.newTransformer();<br>
<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
<br>
&nbsp;&nbsp;&nbsp; // Unless a width is set, there will be only line breaks but no
indentation.<br>
&nbsp;&nbsp;&nbsp; // The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp; // so we set them both.<br>
&nbsp;&nbsp;&nbsp; //<br>
&nbsp;&nbsp;&nbsp;
transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;
transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; if (encoding != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return transformer;<br>
&nbsp; }</small><br>
</blockquote>
So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save.&nbsp; If there's another magic property
value to add to the list, we can do that too.&nbsp; Please let me know how
you solve this...<br>
<br>
(You'd think something like specifying the indentation would be
trivial, but apparently not.&nbsp; But then, you'd think determining the
encoding of an input stream would be pretty basic as well, but that
took years to get right.)<br>
<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunc2u$2fe$1@utils.eclipse.org" type="cite">
<pre wrap="">When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
schema, it is serialized without any indentation. This seems to be due
entirely to the version of JDK used when running the application. Works
fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
there any magical settings for resource save that overcome this problem?
Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

--------------070202040502030102010001--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD indent serialization using JDK 1.5 [message #597736 is a reply to message #66450] Wed, 08 March 2006 22:10 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C642C2.6304DEB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thanks, Ed. A bit of Googling found that this is a known bug in Sun's =
JDK:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446

Unfortunately, it's fixed in 5.0u6(b07) and the current release from Sun =
is 5.0u6(b05). Anyone know if/where I can download a newer build?

The workaround noted in this bug requires wrapping the output stream. =
Ed, is that possible to do easily with the XSD resource writer?

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:duncnk$70q$1@utils.eclipse.org...
Dave,

We do the following:

public class DefaultJAXPConfiguration implements JAXPConfiguration
{
public Transformer createTransformer(String encoding) throws =
TransformerException
{
TransformerFactory transformerFactory =3D =
TransformerFactory.newInstance();
Transformer transformer =3D transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no =
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//
=
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount=
", "2");
=
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount"=
, "2");
if (encoding !=3D null)
{
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG =
option to pass that in during save. If there's another magic property =
value to add to the list, we can do that too. Please let me know how =
you solve this...

(You'd think something like specifying the indentation would be =
trivial, but apparently not. But then, you'd think determining the =
encoding of an input stream would be pretty basic as well, but that took =
years to get right.)



Dave Carlson wrote:=20
When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a =

schema, it is serialized without any indentation. This seems to be due=20
entirely to the version of JDK used when running the application. Works =

fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. =
Are=20
there any magical settings for resource save that overcome this problem? =

Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


=20

------=_NextPart_000_000D_01C642C2.6304DEB0
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Thanks, Ed.&nbsp; A bit of Googling =
found that this=20
is a known bug in Sun's JDK:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2><A=20
href=3D" http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446">htt=
p://bugs.sun.com/bugdatabase/view_bug.do?bug_id=3D6296446</A></FONT></DIV=
>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Unfortunately, it's fixed in 5.0u6(b07) =
and the=20
current release from Sun is 5.0u6(b05).&nbsp; Anyone know if/where I can =

download a newer build?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The workaround noted in this bug =
requires wrapping=20
the output stream.&nbsp; Ed, is that possible to do easily with the XSD =
resource=20
writer?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></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:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>We=20
do the following:<BR>
<BLOCKQUOTE><SMALL>public class DefaultJAXPConfiguration implements=20
JAXPConfiguration<BR>{<BR>&nbsp; public Transformer =
createTransformer(String=20
encoding) throws TransformerException<BR>&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;=20
TransformerFactory transformerFactory =3D=20
TransformerFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp; Transformer=20
transformer =3D =
transformerFactory.newTransformer();<BR><BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.INDENT,=20
"yes");<BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.METHOD,=20
"xml");<BR><BR>&nbsp;&nbsp;&nbsp; // Unless a width is set, there =
will be=20
only line breaks but no indentation.<BR>&nbsp;&nbsp;&nbsp; // The =
IBM JDK=20
and the Sun JDK don't agree on the property =
name,<BR>&nbsp;&nbsp;&nbsp; //=20
so we set them both.<BR>&nbsp;&nbsp;&nbsp; //<BR>&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty("{<A class=3Dmoz-txt-link-freetext=20
=
href=3D"http://xml.apache.org/xalan">http://xml.apache.org/xalan</A>}inde=
nt-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<A=20
class=3Dmoz-txt-link-freetext=20
=
href=3D"http://xml.apache.org/xslt">http://xml.apache.org/xslt</A>}indent=
-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp; if (encoding !=3D =
null)<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
transformer.setOutputProperty(OutputKeys.ENCODING,=20
encoding);<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; return=20
transformer;<BR>&nbsp; }</SMALL><BR></BLOCKQUOTE>So you could =
override this=20
and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
during=20
save.&nbsp; If there's another magic property value to add to the =
list, we can=20
do that too.&nbsp; Please let me know how you solve =
this...<BR><BR>(You'd=20
think something like specifying the indentation would be trivial, but=20
apparently not.&nbsp; But then, you'd think determining the encoding =
of an=20
input stream would be pretty basic as well, but that took years to get =

right.)<BR><BR><BR><BR>Dave Carlson wrote:=20
<BLOCKQUOTE cite=3Dmiddunc2u$2fe$1@utils.eclipse.org =
type=3D"cite"><PRE wrap=3D"">When you are using JDK 1.5 (a.k.a. 5.0) and =
programmatically construct a=20
schema, it is serialized without any indentation. This seems to be due=20
entirely to the version of JDK used when running the application. Works =

fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. =
Are=20
there any magical settings for resource save that overcome this problem? =

Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

------=_NextPart_000_000D_01C642C2.6304DEB0--
Re: XSD indent serialization using JDK 1.5 [message #597746 is a reply to message #66471] Wed, 08 March 2006 22:18 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000401040307080407030800
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.


Dave Carlson wrote:

> Thanks, Ed. A bit of Googling found that this is a known bug in Sun's
> JDK:
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446
>
> Unfortunately, it's fixed in 5.0u6(b07) and the current release from
> Sun is 5.0u6(b05). Anyone know if/where I can download a newer build?
>
> The workaround noted in this bug requires wrapping the output stream.
> Ed, is that possible to do easily with the XSD resource writer?
>
> Dave
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:duncnk$70q$1@utils.eclipse.org...
> Dave,
>
> We do the following:
>
> public class DefaultJAXPConfiguration implements JAXPConfiguration
> {
> public Transformer createTransformer(String encoding) throws
> TransformerException
> {
> TransformerFactory transformerFactory =
> TransformerFactory.newInstance();
> Transformer transformer = transformerFactory.newTransformer();
>
> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> transformer.setOutputProperty(OutputKeys.METHOD, "xml");
>
> // Unless a width is set, there will be only line breaks
> but no indentation.
> // The IBM JDK and the Sun JDK don't agree on the property
> name,
> // so we set them both.
> //
>
> transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
> "2");
>
> transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
> "2");
> if (encoding != null)
> {
> transformer.setOutputProperty(OutputKeys.ENCODING,
> encoding);
> }
> return transformer;
> }
>
> So you could override this and use the
> XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during
> save. If there's another magic property value to add to the list,
> we can do that too. Please let me know how you solve this...
>
> (You'd think something like specifying the indentation would be
> trivial, but apparently not. But then, you'd think determining
> the encoding of an input stream would be pretty basic as well, but
> that took years to get right.)
>
>
>
> Dave Carlson wrote:
>
>>When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
>>schema, it is serialized without any indentation. This seems to be due
>>entirely to the version of JDK used when running the application. Works
>>fine with JDK 1.4.x.
>>
>>I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
>>there any magical settings for resource save that overcome this problem?
>>Suggested workaround to customize the resource impl for XSD model?
>>
>>Thanks,
>> Dave Carlson
>>
>>
>>
>>
>


--------------000401040307080407030800
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">
Dave,<br>
<br>
You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunko0$inp$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Thanks, Ed.&nbsp; A bit of Googling found
that this is a known bug in Sun's JDK:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"><a
href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6296446</a></font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Unfortunately, it's fixed in
5.0u6(b07) and the current release from Sun is 5.0u6(b05).&nbsp; Anyone know
if/where I can download a newer build?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">The workaround noted in this bug
requires wrapping the output stream.&nbsp; Ed, is that possible to do easily
with the XSD resource writer?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Dave</font></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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
We do the following:<br>
<blockquote><small>public class DefaultJAXPConfiguration implements
JAXPConfiguration<br>
{<br>
&nbsp; public Transformer createTransformer(String encoding) throws
TransformerException<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp; Transformer transformer = transformerFactory.newTransformer();<br>
<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
<br>
&nbsp;&nbsp;&nbsp; // Unless a width is set, there will be only line breaks but no
indentation.<br>
&nbsp;&nbsp;&nbsp; // The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp; // so we set them both.<br>
&nbsp;&nbsp;&nbsp; //<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp; if (encoding != null)<br>
&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return transformer;<br>
&nbsp; }</small><br>
</blockquote>
So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG
option to pass that in during save.&nbsp; If there's another magic property
value to add to the list, we can do that too.&nbsp; Please let me know how
you solve this...<br>
<br>
(You'd think something like specifying the indentation would be
trivial, but apparently not.&nbsp; But then, you'd think determining the
encoding of an input stream would be pretty basic as well, but that
took years to get right.)<br>
<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middunc2u$2fe$1@utils.eclipse.org" type="cite">
<pre wrap="">When you are using JDK 1.5 (a.k.a. 5.0) and programmatically construct a
schema, it is serialized without any indentation. This seems to be due
entirely to the version of JDK used when running the application. Works
fine with JDK 1.4.x.

I expect this is due to Sun bundling a different XML parser in JDK 1.5. Are
there any magical settings for resource save that overcome this problem?
Suggested workaround to customize the resource impl for XSD model?

Thanks,
Dave Carlson


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

--------------000401040307080407030800--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD indent serialization using JDK 1.5 [message #597752 is a reply to message #66491] Sat, 11 March 2006 18:40 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C64500.9EE01540
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Sorry to keep bugging you Ed, but one more question...

What is the best way to override a resource factory that is contributed =
by another plugin, in this case override the XSDResourceFactoryImpl? =
The default XSD factory is registered via extension point, as follows. =
If I add a similar exention point in my plugin for the same file =
extension but a different factory, how does EMF choose among the =
alternatives? I assume that I need to register my override factory via =
code in the plugin activator, which will (??) take priority over the =
default factory registered via extension point.

<extension point=3D"org.eclipse.emf.ecore.extension_parser">
<parser type=3D"xsd" =
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" />
</extension>

Thanks!
Dave

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:dunl77$mlr$1@utils.eclipse.org...
Dave,

You can use XSDResourceImpl.save(Writer, Map) so you can pass in a =
wrapped stream if necessary.



------=_NextPart_000_001C_01C64500.9EE01540
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Sorry to keep bugging you Ed, but one =
more=20
question...</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What is the best way to override a =
resource factory=20
that is contributed by another plugin, in this case override the=20
XSDResourceFactoryImpl?&nbsp; The default XSD factory is registered via=20
extension point, as follows.&nbsp; If I add a similar exention point in =
my=20
plugin for the same file extension but a different factory, how does EMF =
choose=20
among the alternatives?&nbsp; I assume that I need to register my =
override=20
factory via code in the plugin activator, which will (??) take priority =
over the=20
default factory registered via extension point.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&lt;extension=20
point=3D"org.eclipse.emf.ecore.extension_parser"&gt;</FONT ></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; &lt;parser type=3D"xsd"=20
class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" /&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&lt;/extension&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; Dave</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT>&nbsp;</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:dunl77$mlr$1@utils.eclipse.org">news:dunl77$mlr$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>You=20
can use XSDResourceImpl.save(Writer, Map) so you can pass in a wrapped =
stream=20
if necessary.<BR><BR><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_001C_01C64500.9EE01540--
Re: XSD indent serialization using JDK 1.5 [message #597757 is a reply to message #66450] Sat, 11 March 2006 20:31 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

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

"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:duncnk$70q$1@utils.eclipse.org...

> So you could override this and use the XSDResourceImpl.XSD_JAXP_CONFIG =
option to pass that in during save. If there's another magic property=20
> value to add to the list, we can do that too. Please let me know how =
you solve this...

Ed,=20
I have a solution working under JDK 5.0u6 (the current release from =
Sun). Two changes are necessary
- add the Xerces specific "indent-number" to the JAXP transformation =
factory
transformerFactory.setAttribute("indent-number", new Integer(2));

- use a Writer instead of an OutputStream

I had been using Resource.save(options), but that uses an outputstream. =
So I wrote a simple utility class with a static helper. I asked about =
overriding the XSDResourceFactoryImpl, but no longer need to do that. =
But still interested in the best practice for this.

My solution looks like this:

public class XSDResourceUtil {

public static void save(XSDSchema schema, URI fileURI, ResourceSet =
resourceSet)
throws IOException {
XSDResourceImpl resource =3D new XSDResourceImpl(fileURI);
resource.getContents().add(schema);
resourceSet.getResources().add(resource);

URIConverter uriConverter =3D resourceSet.getURIConverter();
OutputStream outputStream =3D =
uriConverter.createOutputStream(fileURI);
Writer writer =3D new OutputStreamWriter(outputStream, "utf-8");

Map options =3D new HashMap();
options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new =
XercesJAXPConfiguration());
try {
resource.save(writer, options);
} finally {
writer.close();
}
}


private static class XercesJAXPConfiguration extends =
DefaultJAXPConfiguration {

public XercesJAXPConfiguration() {
super();
}

public Transformer createTransformer(String encoding) throws =
TransformerException {
TransformerFactory transformerFactory =3D =
TransformerFactory.newInstance();
=20
// workaround for JDK 1.5.0u6 and before
transformerFactory.setAttribute("indent-number", new Integer(2));
=20
Transformer transformer =3D transformerFactory.newTransformer();

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");

// Unless a width is set, there will be only line breaks but no =
indentation.
// The IBM JDK and the Sun JDK don't agree on the property name,
// so we set them both.
//
=
transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount=
", "2");
=
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount"=
, "2");
if (encoding !=3D null) {
transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
return transformer;
}

}
}

------=_NextPart_000_0035_01C64510.1EAFAA60
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff background=3D"">
<DIV><FONT face=3DArial size=3D2>"Ed Merks" &lt;merks@ca.ibm.com&gt; =
wrote in=20
message news:duncnk$70q$1@utils.eclipse.org...<BR><BR>&gt; So you could =
override=20
this and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
during=20
save.&nbsp; If there's another magic property </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt; value to add to the list, we can =
do that=20
too.&nbsp; Please let me know how you solve this...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ed, </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a solution working under JDK =
5.0u6 (the=20
current release from Sun).&nbsp; Two changes are necessary</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>- add the Xerces specific =
"indent-number" to=20
the&nbsp;JAXP transformation factory</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;=20
transformerFactory.setAttribute("indent-number", new =
Integer(2));</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- use a Writer instead of an=20
OutputStream</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I had been using =
Resource.save(options), but that=20
uses an outputstream.&nbsp; So I wrote a simple utility class with a =
static=20
helper.&nbsp; I asked about overriding the XSDResourceFactoryImpl, but =
no longer=20
need to do that.&nbsp; But still interested in the best practice for=20
this.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My solution looks like =
this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>public class XSDResourceUtil =
{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;public static void save(XSDSchema =
schema, URI=20
fileURI, ResourceSet resourceSet)<BR>&nbsp;&nbsp;&nbsp;throws =
IOException=20
{<BR>&nbsp;&nbsp;XSDResourceImpl resource =3D new=20
XSDResourceImpl(fileURI);<BR>&nbsp;&nbsp;resource.getContents().add(schem=
a);<BR> &nbsp;&nbsp;resourceSet.getResources().add(resource) ; </FONT></DIV>=

<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;URIConverter uriConverter =
=3D=20
resourceSet.getURIConverter();<BR>&nbsp;&nbsp;OutputStream outputStream =
=3D=20
uriConverter.createOutputStream(fileURI);<BR>&nbsp;<FONT=20
color=3D#ff0000>&nbsp;Writer writer =3D new =
OutputStreamWriter(outputStream,=20
"utf-8");</FONT></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;Map options =3D new=20
HashMap();<BR>&nbsp;&nbsp;<STRONG><FONT=20
color=3D#ff0000>options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new=20
XercesJAXPConfiguration());<BR></FONT></STRONG>&nbsp;&nbsp;try=20
{<BR>&nbsp;&nbsp;<FONT color=3D#ff0000>&nbsp;resource.save(writer,=20
options);<BR></FONT>&nbsp;&nbsp;} finally=20
{<BR>&nbsp;&nbsp;&nbsp;writer.close();<BR>&nbsp;&nbsp;} <BR>&nbsp;}</FONT>=
</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><BR><FONT face=3DArial size=3D2>&nbsp;private static class=20
XercesJAXPConfiguration extends DefaultJAXPConfiguration {</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;public =
XercesJAXPConfiguration()=20
{<BR>&nbsp;&nbsp;&nbsp;super();<BR>&nbsp;&nbsp;} </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;public Transformer=20
createTransformer(String encoding) throws TransformerException=20
{<BR>&nbsp;&nbsp;&nbsp;TransformerFactory transformerFactory =3D=20
TransformerFactory.newInstance();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;<F=
ONT=20
color=3D#ff0000><STRONG>&nbsp;// workaround for JDK 1.5.0u6 and=20
before<BR> &nbsp;&nbsp;&nbsp;transformerFactory.setAttribut e( "indent-numbe=
r", new=20
Integer(2));<BR></STRONG></FONT>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;T=
ransformer=20
transformer =3D transformerFactory.newTransformer();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.INDEN=
T,=20
"yes");<BR> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.MET=
HOD,=20
"xml");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;// Unless a width is =
set, there=20
will be only line breaks but no indentation.<BR>&nbsp;&nbsp;&nbsp;// The =
IBM JDK=20
and the Sun JDK don't agree on the property =
name,<BR>&nbsp;&nbsp;&nbsp;// so we=20
set them=20
both.<BR>&nbsp;&nbsp;&nbsp;//<BR>&nbsp;&nbsp;&nbsp;transformer.setOutputP=
roperty("{http://xml.apache.org/xalan}indent-amount",=20
"2");<BR> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{http://xml.apa=
che.org/xslt}indent-amount",=20
"2");<BR>&nbsp;&nbsp;&nbsp;if (encoding !=3D null)=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;transformer.setOutpu tProperty(OutputKeys.ENC=
ODING,=20
encoding);<BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;return=20
transformer;<BR>&nbsp;&nbsp;}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;}<BR>}<BR></FONT></DIV></BODY></HTML >

------=_NextPart_000_0035_01C64510.1EAFAA60--
Re: XSD indent serialization using JDK 1.5 [message #597766 is a reply to message #66512] Mon, 13 March 2006 11:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080006010504090300080909
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

There can only be one global registration, but you can make a local
registration in any ResourceSet via getResourceFactoryRegistry().


Dave Carlson wrote:

> Sorry to keep bugging you Ed, but one more question...
>
> What is the best way to override a resource factory that is
> contributed by another plugin, in this case override the
> XSDResourceFactoryImpl? The default XSD factory is registered via
> extension point, as follows. If I add a similar exention point in my
> plugin for the same file extension but a different factory, how does
> EMF choose among the alternatives? I assume that I need to register
> my override factory via code in the plugin activator, which will (??)
> take priority over the default factory registered via extension point.
>
> <extension point="org.eclipse.emf.ecore.extension_parser">
> <parser type="xsd"
> class="org.eclipse.xsd.util.XSDResourceFactoryImpl" />
> </extension>
>
> Thanks!
> Dave
>
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:dunl77$mlr$1@utils.eclipse.org...
> Dave,
>
> You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
> wrapped stream if necessary.
>
>


--------------080006010504090300080909
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">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Dave,<br>
<br>
There can only be one global registration, but you can make a local
registration in any ResourceSet via getResourceFactoryRegistry().<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midduv5la$ijn$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Sorry to keep bugging you Ed, but
one more question...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">What is the best way to override a
resource factory that is contributed by another plugin, in this case
override the XSDResourceFactoryImpl?&nbsp; The default XSD factory is
registered via extension point, as follows.&nbsp; If I add a similar
exention point in my plugin for the same file extension but a different
factory, how does EMF choose among the alternatives?&nbsp; I assume that I
need to register my override factory via code in the plugin activator,
which will (??) take priority over the default factory registered via
extension point.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&lt;extension
point="org.eclipse.emf.ecore.extension_parser"&gt;</font ></div>
<div><font face="Arial" size="2">&nbsp;&nbsp; &lt;parser type="xsd"
class="org.eclipse.xsd.util.XSDResourceFactoryImpl" /&gt;</font></div>
<div><font face="Arial" size="2">&lt;/extension&gt;</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Thanks!</font></div>
<div><font face="Arial" size="2">&nbsp; Dave</font></div>
<div>&nbsp;</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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:dunl77$mlr$1@utils.eclipse.org">news:dunl77$mlr$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
You can use XSDResourceImpl.save(Writer, Map) so you can pass in a
wrapped stream if necessary.<br>
<br>
<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080006010504090300080909--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD indent serialization using JDK 1.5 [message #597775 is a reply to message #66535] Mon, 13 March 2006 12:16 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080704090600050406070604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

XSDResourceImpl has this verison of save already:

public final void save(Writer writer, Map options) throws IOException

Wouldn't that work?


Dave Carlson wrote:

> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:duncnk$70q$1@utils.eclipse.org...
>
> > So you could override this and use the
> XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during save.
> If there's another magic property
> > value to add to the list, we can do that too. Please let me know
> how you solve this...
>
> Ed,
> I have a solution working under JDK 5.0u6 (the current release from
> Sun). Two changes are necessary
> - add the Xerces specific "indent-number" to the JAXP transformation
> factory
> transformerFactory.setAttribute("indent-number", new Integer(2));
>
> - use a Writer instead of an OutputStream
>
> I had been using Resource.save(options), but that uses an
> outputstream. So I wrote a simple utility class with a static
> helper. I asked about overriding the XSDResourceFactoryImpl, but no
> longer need to do that. But still interested in the best practice for
> this.
>
> My solution looks like this:
>
> public class XSDResourceUtil {
>
> public static void save(XSDSchema schema, URI fileURI, ResourceSet
> resourceSet)
> throws IOException {
> XSDResourceImpl resource = new XSDResourceImpl(fileURI);
> resource.getContents().add(schema);
> resourceSet.getResources().add(resource);
>
> URIConverter uriConverter = resourceSet.getURIConverter();
> OutputStream outputStream = uriConverter.createOutputStream(fileURI);
> Writer writer = new OutputStreamWriter(outputStream, "utf-8");
>
> Map options = new HashMap();
> *options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new
> XercesJAXPConfiguration());
> * try {
> resource.save(writer, options);
> } finally {
> writer.close();
> }
> }
>
>
> private static class XercesJAXPConfiguration extends
> DefaultJAXPConfiguration {
>
> public XercesJAXPConfiguration() {
> super();
> }
>
> public Transformer createTransformer(String encoding) throws
> TransformerException {
> TransformerFactory transformerFactory =
> TransformerFactory.newInstance();
>
> * // workaround for JDK 1.5.0u6 and before
> transformerFactory.setAttribute("indent-number", new Integer(2));
> *
> Transformer transformer = transformerFactory.newTransformer();
>
> transformer.setOutputProperty(OutputKeys.INDENT, "yes");
> transformer.setOutputProperty(OutputKeys.METHOD, "xml");
>
> // Unless a width is set, there will be only line breaks but no
> indentation.
> // The IBM JDK and the Sun JDK don't agree on the property name,
> // so we set them both.
> //
> transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount",
> "2");
> transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
> "2");
> if (encoding != null) {
> transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
> }
> return transformer;
> }
>
> }
> }



--------------080704090600050406070604
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">
Dave,<br>
<br>
XSDResourceImpl has this verison of save already:<br>
<br>
&nbsp; public final void save(Writer writer, Map options) throws IOException<br>
<br>
Wouldn't that work?<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="midduvc5a$vlr$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a>
wrote in message <a class="moz-txt-link-freetext" href="news:duncnk$70q$1@utils.eclipse.org">news:duncnk$70q$1@utils.eclipse.org</a>...<br>
<br>
&gt; So you could override this and use the
XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in during save.&nbsp; If
there's another magic property </font></div>
<div><font face="Arial" size="2">&gt; value to add to the list, we
can do that too.&nbsp; Please let me know how you solve this...</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Ed, </font></div>
<div><font face="Arial" size="2">I have a solution working under JDK
5.0u6 (the current release from Sun).&nbsp; Two changes are necessary</font></div>
<div><font face="Arial" size="2">- add the Xerces specific
"indent-number" to the&nbsp;JAXP transformation factory</font></div>
<div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp;
transformerFactory.setAttribute("indent-number", new Integer(2));</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">- use a Writer instead of an
OutputStream</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">I had been using
Resource.save(options), but that uses an outputstream.&nbsp; So I wrote a
simple utility class with a static helper.&nbsp; I asked about overriding
the XSDResourceFactoryImpl, but no longer need to do that.&nbsp; But still
interested in the best practice for this.</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">My solution looks like this:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">public class XSDResourceUtil {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;public static void save(XSDSchema
schema, URI fileURI, ResourceSet resourceSet)<br>
&nbsp;&nbsp;&nbsp;throws IOException {<br>
&nbsp;&nbsp;XSDResourceImpl resource = new XSDResourceImpl(fileURI);<br>
&nbsp;&nbsp;resource.getContents().add(schema);<br>
&nbsp;&nbsp;resourceSet.getResources().add(resource) ; </font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;URIConverter uriConverter =
resourceSet.getURIConverter();<br>
&nbsp;&nbsp;OutputStream outputStream = uriConverter.createOutputStream(fileURI);<br>
&nbsp;<font color="#ff0000">&nbsp;Writer writer = new
OutputStreamWriter(outputStream, "utf-8");</font></font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;Map options = new HashMap();<br>
&nbsp;&nbsp;<strong><font color="#ff0000">options.put(XSDResourceImpl.XSD_JAXP_CONFIG,
new XercesJAXPConfiguration());<br>
</font></strong>&nbsp;&nbsp;try {<br>
&nbsp;&nbsp;<font color="#ff0000">&nbsp;resource.save(writer, options);<br>
</font>&nbsp;&nbsp;} finally {<br>
&nbsp;&nbsp;&nbsp;writer.close();<br>
&nbsp;&nbsp;}<br>
&nbsp;}</font></div>
<div>&nbsp;</div>
<div><br>
<font face="Arial" size="2">&nbsp;private static class
XercesJAXPConfiguration extends DefaultJAXPConfiguration {</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;public XercesJAXPConfiguration() {<br>
&nbsp;&nbsp;&nbsp;super();<br>
&nbsp;&nbsp;}</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;public Transformer
createTransformer(String encoding) throws TransformerException {<br>
&nbsp;&nbsp;&nbsp;TransformerFactory transformerFactory =
TransformerFactory.newInstance();<br>
&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#ff0000"><strong>&nbsp;// workaround for JDK 1.5.0u6 and
before<br>
&nbsp;&nbsp;&nbsp;transformerFactory.setAttribut e( "indent-number", new Integer(2));<br>
</strong></font>&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;Transformer transformer = transformerFactory.newTransformer();</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2"> &nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.INDENT,
"yes");<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( OutputKeys.METHOD, "xml");</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;&nbsp;&nbsp;// Unless a width is set, there
will be only line breaks but no indentation.<br>
&nbsp;&nbsp;&nbsp;// The IBM JDK and the Sun JDK don't agree on the property name,<br>
&nbsp;&nbsp;&nbsp;// so we set them both.<br>
&nbsp;&nbsp;&nbsp;//<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
"2");<br>
&nbsp;&nbsp;&nbsp;if (encoding != null) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;transformer.setOutpu tProperty(OutputKeys.ENCODING, encoding);<br>
&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;return transformer;<br>
&nbsp;&nbsp;}</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">&nbsp;}<br>
}<br>
</font></div>
</blockquote>
<br>
</body>
</html>

--------------080704090600050406070604--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSD indent serialization using JDK 1.5 [message #597780 is a reply to message #66578] Mon, 13 March 2006 15:15 Go to previous message
Dave Carlson is currently offline Dave CarlsonFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C64676.3E79E920
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Yes, except that in my code it is usually most convenient to call:

resource.save(options);

This method uses the resource URI to write the file, but it always uses =
an OutputStream. I need to study exactly what the URIConverter does on =
the resource.save() implementation, and if it's necessary in my case. =
To use the save method that you list here, would I need to include the =
URIConverter code anyplace I wanted to save an XSD resource? =
Could/should the resource.save(options) implementation use Writer =
instead of OutputStream?

Dave
"Ed Merks" <merks@ca.ibm.com> wrote in message =
news:dv3nu0$efj$1@utils.eclipse.org...
Dave,

XSDResourceImpl has this verison of save already:

public final void save(Writer writer, Map options) throws =
IOException

Wouldn't that work?

------=_NextPart_000_000A_01C64676.3E79E920
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.2802" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Yes, except that in my code it is =
usually most=20
convenient to call:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>resource.save(options);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>This method uses the resource URI to =
write the=20
file, but it always uses an OutputStream.&nbsp; I need to study exactly =
what the=20
URIConverter does on the resource.save() implementation, and if it's =
necessary=20
in my case.&nbsp; To use the save method that you list here, would I =
need to=20
include the URIConverter code anyplace I wanted to save an XSD =
resource?&nbsp;=20
Could/should the resource.save(options) implementation use Writer =
instead of=20
OutputStream?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Dave</FONT></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:dv3nu0$efj$1@utils.eclipse.org">news:dv3nu0$efj$1@utils.ecli=
pse.org</A>...</DIV>Dave,<BR><BR>XSDResourceImpl=20
has this verison of save already:<BR><BR>&nbsp; public final void =
save(Writer=20
writer, Map options) throws IOException<BR><BR>Wouldn't that=20
work?<BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000A_01C64676.3E79E920--
Re: XSD indent serialization using JDK 1.5 [message #597786 is a reply to message #66599] Mon, 13 March 2006 15:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080106090600090702010904
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Dave,

The URI converter simply opens a stream so if you want to open the
stream some other way, that's fine; or you can always call the URI
converter directly to open the stream. In EMF 2.2, we've introduced
URIConverter.ReadonableInputStream/WriteableOutputStream to allow a
wrapped reader or writer to be passed as an input or output stream using
the existing APIs (which we would not consider changing) and these may
be unwrapped by the resource implementation (as the resources in the XMI
plugin do) to access the reader or writer directly.


Dave Carlson wrote:

> Yes, except that in my code it is usually most convenient to call:
>
> resource.save(options);
>
> This method uses the resource URI to write the file, but it always
> uses an OutputStream. I need to study exactly what the URIConverter
> does on the resource.save() implementation, and if it's necessary in
> my case. To use the save method that you list here, would I need to
> include the URIConverter code anyplace I wanted to save an XSD
> resource? Could/should the resource.save(options) implementation use
> Writer instead of OutputStream?
>
> Dave
>
> "Ed Merks" <merks@ca.ibm.com <mailto:merks@ca.ibm.com>> wrote in
> message news:dv3nu0$efj$1@utils.eclipse.org...
> Dave,
>
> XSDResourceImpl has this verison of save already:
>
> public final void save(Writer writer, Map options) throws
> IOException
>
> Wouldn't that work?
>


--------------080106090600090702010904
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">
Dave,<br>
<br>
The URI converter simply opens a stream so if you want to open the
stream some other way, that's fine; or you can always call the URI
converter directly to open the stream.&nbsp; In EMF 2.2, we've introduced
URIConverter.ReadonableInputStream/WriteableOutputStream to allow a
wrapped reader or writer to be passed as an input or output stream
using the existing APIs (which we would not consider changing) and
these may be unwrapped by the resource implementation (as the resources
in the XMI plugin do) to access the reader or writer directly.<br>
<br>
<br>
Dave Carlson wrote:
<blockquote cite="middv42d7$qbt$1@utils.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.2900.2802" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Yes, except that in my code it is
usually most convenient to call:</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">resource.save(options);</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">This method uses the resource URI to
write the file, but it always uses an OutputStream.&nbsp; I need to study
exactly what the URIConverter does on the resource.save()
implementation, and if it's necessary in my case.&nbsp; To use the save
method that you list here, would I need to include the URIConverter
code anyplace I wanted to save an XSD resource?&nbsp; Could/should the
resource.save(options) implementation use Writer instead of
OutputStream?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Dave</font></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 href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>&gt;
wrote in message <a href="news:dv3nu0$efj$1@utils.eclipse.org">news:dv3nu0$efj$1@utils.eclipse.org</a>...</div>
Dave,<br>
<br>
XSDResourceImpl has this verison of save already:<br>
<br>
&nbsp; public final void save(Writer writer, Map options) throws IOException<br>
<br>
Wouldn't that work?<br>
</blockquote>
</blockquote>
<br>
</body>
</html>

--------------080106090600090702010904--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:XSD indent serialization using JDK 1.5
Next Topic:extension base
Goto Forum:
  


Current Time: Thu Apr 18 04:56:26 GMT 2024

Powered by FUDForum. Page generated in 0.03319 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top