| Home » Archived » XML Schema Definition (XSD) » XSD indent serialization using JDK 1.5
 Goto Forum:| 
| XSD indent serialization using JDK 1.5 [message #66431] | Wed, 08 March 2006 14:42  |  | 
| Eclipse User  |  |  |  |  | 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 14:53   |  | 
| Eclipse User  |  |  |  |  | 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>
   public Transformer createTransformer(String encoding) throws
 TransformerException<br>
   {<br>
     TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
     Transformer transformer = transformerFactory.newTransformer();<br>
 <br>
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
     transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
 <br>
     // Unless a width is set, there will be only line breaks but no
 indentation.<br>
     // The IBM JDK and the Sun JDK don't agree on the property name,<br>
     // so we set them both.<br>
     //<br>
    
 transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
    
 transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
     if (encoding != null)<br>
     {<br>
       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
     }<br>
     return transformer;<br>
   }</small><br>
 </blockquote>
 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...<br>
 <br>
 (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.)<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 17:10   |  | 
| Eclipse User  |  |  |  |  | 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.  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> </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> </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).  Anyone know if/where I can =
 
 download a newer build?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>The workaround noted in this bug =
 requires wrapping=20
 the output stream.  Ed, is that possible to do easily with the XSD =
 resource=20
 writer?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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>  public Transformer =
 createTransformer(String=20
 encoding) throws TransformerException<BR>  =
 {<BR>   =20
 TransformerFactory transformerFactory =3D=20
 TransformerFactory.newInstance();<BR>    Transformer=20
 transformer =3D =
 transformerFactory.newTransformer();<BR><BR>   =20
 transformer.setOutputProperty(OutputKeys.INDENT,=20
 "yes");<BR>   =20
 transformer.setOutputProperty(OutputKeys.METHOD,=20
 "xml");<BR><BR>    // Unless a width is set, there =
 will be=20
 only line breaks but no indentation.<BR>    // The =
 IBM JDK=20
 and the Sun JDK don't agree on the property =
 name,<BR>    //=20
 so we set them both.<BR>    //<BR>   =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>    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>    if (encoding !=3D =
 null)<BR>   =20
 {<BR>     =20
 transformer.setOutputProperty(OutputKeys.ENCODING,=20
 encoding);<BR>    }<BR>    return=20
 transformer;<BR>  }</SMALL><BR></BLOCKQUOTE>So you could =
 override this=20
 and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
 during=20
 save.  If there's another magic property value to add to the =
 list, we can=20
 do that too.  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.  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 17:18   |  | 
| Eclipse User  |  |  |  |  | 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.  A bit of Googling found
 that this is a known bug in Sun's JDK:</font></div>
 <div> </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> </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).  Anyone know
 if/where I can download a newer build?</font></div>
 <div> </div>
 <div><font face="Arial" size="2">The workaround noted in this bug
 requires wrapping the output stream.  Ed, is that possible to do easily
 with the XSD resource writer?</font></div>
 <div> </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" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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>
   public Transformer createTransformer(String encoding) throws
 TransformerException<br>
   {<br>
     TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
     Transformer transformer = transformerFactory.newTransformer();<br>
 <br>
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
     transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
 <br>
     // Unless a width is set, there will be only line breaks but no
 indentation.<br>
     // The IBM JDK and the Sun JDK don't agree on the property name,<br>
     // so we set them both.<br>
     //<br>
     transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
 href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
     transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
 href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
     if (encoding != null)<br>
     {<br>
       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
     }<br>
     return transformer;<br>
   }</small><br>
 </blockquote>
 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...<br>
 <br>
 (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.)<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 13:40   |  | 
| Eclipse User  |  |  |  |  | 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> </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?  The default XSD factory is registered via=20
 extension point, as follows.  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?  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> </DIV>
 <DIV><FONT face=3DArial size=3D2><extension=20
 point=3D"org.eclipse.emf.ecore.extension_parser"></FONT ></DIV>
 <DIV><FONT face=3DArial size=3D2>   <parser type=3D"xsd"=20
 class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" /></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></extension></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>  Dave</FONT></DIV>
 <DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
 size=3D2></FONT></FONT></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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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 15:31   |  | 
| Eclipse User  |  |  |  |  | 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" <merks@ca.ibm.com> =
 wrote in=20
 message news:duncnk$70q$1@utils.eclipse.org...<BR><BR>> So you could =
 override=20
 this and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
 during=20
 save.  If there's another magic property </FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>> value to add to the list, we can =
 do that=20
 too.  Please let me know how you solve this...</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
 size=3D2></FONT> </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).  Two changes are necessary</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>- add the Xerces specific =
 "indent-number" to=20
 the JAXP transformation factory</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>   =20
 transformerFactory.setAttribute("indent-number", new =
 Integer(2));</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>- use a Writer instead of an=20
 OutputStream</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>I had been using =
 Resource.save(options), but that=20
 uses an outputstream.  So I wrote a simple utility class with a =
 static=20
 helper.  I asked about overriding the XSDResourceFactoryImpl, but =
 no longer=20
 need to do that.  But still interested in the best practice for=20
 this.</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>My solution looks like =
 this:</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>public class XSDResourceUtil =
 {</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2> public static void save(XSDSchema =
 schema, URI=20
 fileURI, ResourceSet resourceSet)<BR>   throws =
 IOException=20
 {<BR>  XSDResourceImpl resource =3D new=20
 XSDResourceImpl(fileURI);<BR>  resource.getContents().add(schem=
 a);<BR>   resourceSet.getResources().add(resource) ; </FONT></DIV>=
 
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  URIConverter uriConverter =
 =3D=20
 resourceSet.getURIConverter();<BR>  OutputStream outputStream =
 =3D=20
 uriConverter.createOutputStream(fileURI);<BR> <FONT=20
 color=3D#ff0000> Writer writer =3D new =
 OutputStreamWriter(outputStream,=20
 "utf-8");</FONT></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  Map options =3D new=20
 HashMap();<BR>  <STRONG><FONT=20
 color=3D#ff0000>options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new=20
 XercesJAXPConfiguration());<BR></FONT></STRONG>  try=20
 {<BR>  <FONT color=3D#ff0000> resource.save(writer,=20
 options);<BR></FONT>  } finally=20
 {<BR>   writer.close();<BR>  } <BR> }</FONT>=
 </DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><BR><FONT face=3DArial size=3D2> private static class=20
 XercesJAXPConfiguration extends DefaultJAXPConfiguration {</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  public =
 XercesJAXPConfiguration()=20
 {<BR>   super();<BR>  } </FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  public Transformer=20
 createTransformer(String encoding) throws TransformerException=20
 {<BR>   TransformerFactory transformerFactory =3D=20
 TransformerFactory.newInstance();<BR>    <BR>  <F=
 ONT=20
 color=3D#ff0000><STRONG> // workaround for JDK 1.5.0u6 and=20
 before<BR>    transformerFactory.setAttribut e( "indent-numbe=
 r", new=20
 Integer(2));<BR></STRONG></FONT>    <BR>   T=
 ransformer=20
 transformer =3D transformerFactory.newTransformer();</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial=20
 size=3D2>    transformer.setOutputProperty( OutputKeys.INDEN=
 T,=20
 "yes");<BR>    transformer.setOutputProperty( OutputKeys.MET=
 HOD,=20
 "xml");</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>   // Unless a width is =
 set, there=20
 will be only line breaks but no indentation.<BR>   // The =
 IBM JDK=20
 and the Sun JDK don't agree on the property =
 name,<BR>   // so we=20
 set them=20
 both.<BR>   //<BR>   transformer.setOutputP=
 roperty("{http://xml.apache.org/xalan}indent-amount",=20
 "2");<BR>    transformer.setOutputProperty( "{http://xml.apa=
 che.org/xslt}indent-amount",=20
 "2");<BR>   if (encoding !=3D null)=20
 {<BR>     transformer.setOutpu tProperty(OutputKeys.ENC=
 ODING,=20
 encoding);<BR>   }<BR>   return=20
 transformer;<BR>  }</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial =
 size=3D2> }<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 06:49   |  | 
| Eclipse User  |  |  |  |  | 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> </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?  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.</font></div>
 <div> </div>
 <div><font face="Arial" size="2"><extension
 point="org.eclipse.emf.ecore.extension_parser"></font ></div>
 <div><font face="Arial" size="2">   <parser type="xsd"
 class="org.eclipse.xsd.util.XSDResourceFactoryImpl" /></font></div>
 <div><font face="Arial" size="2"></extension></font></div>
 <div> </div>
 <div><font face="Arial" size="2">Thanks!</font></div>
 <div><font face="Arial" size="2">  Dave</font></div>
 <div> </div>
 <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
 <div>"Ed Merks" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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 07:16   |  | 
| Eclipse User  |  |  |  |  | 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>
   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"><merks@ca.ibm.com></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>
 > 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 </font></div>
 <div><font face="Arial" size="2">> value to add to the list, we
 can do that too.  Please let me know how you solve this...</font></div>
 <div> </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).  Two changes are necessary</font></div>
 <div><font face="Arial" size="2">- add the Xerces specific
 "indent-number" to the JAXP transformation factory</font></div>
 <div><font face="Arial" size="2">   
 transformerFactory.setAttribute("indent-number", new Integer(2));</font></div>
 <div> </div>
 <div><font face="Arial" size="2">- use a Writer instead of an
 OutputStream</font></div>
 <div> </div>
 <div><font face="Arial" size="2">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.</font></div>
 <div> </div>
 <div><font face="Arial" size="2">My solution looks like this:</font></div>
 <div> </div>
 <div><font face="Arial" size="2">public class XSDResourceUtil {</font></div>
 <div> </div>
 <div><font face="Arial" size="2"> public static void save(XSDSchema
 schema, URI fileURI, ResourceSet resourceSet)<br>
    throws IOException {<br>
   XSDResourceImpl resource = new XSDResourceImpl(fileURI);<br>
   resource.getContents().add(schema);<br>
   resourceSet.getResources().add(resource) ; </font></div>
 <div> </div>
 <div><font face="Arial" size="2">  URIConverter uriConverter =
 resourceSet.getURIConverter();<br>
   OutputStream outputStream = uriConverter.createOutputStream(fileURI);<br>
  <font color="#ff0000"> Writer writer = new
 OutputStreamWriter(outputStream, "utf-8");</font></font></div>
 <div> </div>
 <div><font face="Arial" size="2">  Map options = new HashMap();<br>
   <strong><font color="#ff0000">options.put(XSDResourceImpl.XSD_JAXP_CONFIG,
 new XercesJAXPConfiguration());<br>
 </font></strong>  try {<br>
   <font color="#ff0000"> resource.save(writer, options);<br>
 </font>  } finally {<br>
    writer.close();<br>
   }<br>
  }</font></div>
 <div> </div>
 <div><br>
 <font face="Arial" size="2"> private static class
 XercesJAXPConfiguration extends DefaultJAXPConfiguration {</font></div>
 <div> </div>
 <div><font face="Arial" size="2">  public XercesJAXPConfiguration() {<br>
    super();<br>
   }</font></div>
 <div> </div>
 <div><font face="Arial" size="2">  public Transformer
 createTransformer(String encoding) throws TransformerException {<br>
    TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
    <br>
   <font color="#ff0000"><strong> // workaround for JDK 1.5.0u6 and
 before<br>
    transformerFactory.setAttribut e( "indent-number", new Integer(2));<br>
 </strong></font>   <br>
    Transformer transformer = transformerFactory.newTransformer();</font></div>
 <div> </div>
 <div><font face="Arial" size="2">    transformer.setOutputProperty( OutputKeys.INDENT,
 "yes");<br>
    transformer.setOutputProperty( OutputKeys.METHOD, "xml");</font></div>
 <div> </div>
 <div><font face="Arial" size="2">   // Unless a width is set, there
 will be only line breaks but no indentation.<br>
    // The IBM JDK and the Sun JDK don't agree on the property name,<br>
    // so we set them both.<br>
    //<br>
    transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
    transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
    if (encoding != null) {<br>
     transformer.setOutpu tProperty(OutputKeys.ENCODING, encoding);<br>
    }<br>
    return transformer;<br>
   }</font></div>
 <div> </div>
 <div><font face="Arial" size="2"> }<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 10:15   |  | 
| Eclipse User  |  |  |  |  | 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> </DIV>
 <DIV><FONT face=3DArial size=3D2>resource.save(options);</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>This method uses the resource URI to =
 write the=20
 file, but it always uses an OutputStream.  I need to study exactly =
 what the=20
 URIConverter does on the resource.save() implementation, and if it's =
 necessary=20
 in my case.  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? =20
 Could/should the resource.save(options) implementation use Writer =
 instead of=20
 OutputStream?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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>  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 10:26  |  | 
| Eclipse User  |  |  |  |  | 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.  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> </div>
 <div><font face="Arial" size="2">resource.save(options);</font></div>
 <div> </div>
 <div><font face="Arial" size="2">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?</font></div>
 <div> </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" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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>
   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 14:53  |  | 
| Eclipse User  |  |  |  |  | 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>
   public Transformer createTransformer(String encoding) throws
 TransformerException<br>
   {<br>
     TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
     Transformer transformer = transformerFactory.newTransformer();<br>
 <br>
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
     transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
 <br>
     // Unless a width is set, there will be only line breaks but no
 indentation.<br>
     // The IBM JDK and the Sun JDK don't agree on the property name,<br>
     // so we set them both.<br>
     //<br>
    
 transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
    
 transformer.setOutputProperty("{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
     if (encoding != null)<br>
     {<br>
       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
     }<br>
     return transformer;<br>
   }</small><br>
 </blockquote>
 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...<br>
 <br>
 (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.)<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 #597736 is a reply to message #66450] | Wed, 08 March 2006 17:10  |  | 
| Eclipse User  |  |  |  |  | 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.  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> </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> </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).  Anyone know if/where I can =
 
 download a newer build?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>The workaround noted in this bug =
 requires wrapping=20
 the output stream.  Ed, is that possible to do easily with the XSD =
 resource=20
 writer?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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>  public Transformer =
 createTransformer(String=20
 encoding) throws TransformerException<BR>  =
 {<BR>   =20
 TransformerFactory transformerFactory =3D=20
 TransformerFactory.newInstance();<BR>    Transformer=20
 transformer =3D =
 transformerFactory.newTransformer();<BR><BR>   =20
 transformer.setOutputProperty(OutputKeys.INDENT,=20
 "yes");<BR>   =20
 transformer.setOutputProperty(OutputKeys.METHOD,=20
 "xml");<BR><BR>    // Unless a width is set, there =
 will be=20
 only line breaks but no indentation.<BR>    // The =
 IBM JDK=20
 and the Sun JDK don't agree on the property =
 name,<BR>    //=20
 so we set them both.<BR>    //<BR>   =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>    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>    if (encoding !=3D =
 null)<BR>   =20
 {<BR>     =20
 transformer.setOutputProperty(OutputKeys.ENCODING,=20
 encoding);<BR>    }<BR>    return=20
 transformer;<BR>  }</SMALL><BR></BLOCKQUOTE>So you could =
 override this=20
 and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
 during=20
 save.  If there's another magic property value to add to the =
 list, we can=20
 do that too.  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.  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 17:18  |  | 
| Eclipse User  |  |  |  |  | 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.  A bit of Googling found
 that this is a known bug in Sun's JDK:</font></div>
 <div> </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> </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).  Anyone know
 if/where I can download a newer build?</font></div>
 <div> </div>
 <div><font face="Arial" size="2">The workaround noted in this bug
 requires wrapping the output stream.  Ed, is that possible to do easily
 with the XSD resource writer?</font></div>
 <div> </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" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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>
   public Transformer createTransformer(String encoding) throws
 TransformerException<br>
   {<br>
     TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
     Transformer transformer = transformerFactory.newTransformer();<br>
 <br>
     transformer.setOutputProperty(OutputKeys.INDENT, "yes");<br>
     transformer.setOutputProperty(OutputKeys.METHOD, "xml");<br>
 <br>
     // Unless a width is set, there will be only line breaks but no
 indentation.<br>
     // The IBM JDK and the Sun JDK don't agree on the property name,<br>
     // so we set them both.<br>
     //<br>
     transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
 href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
     transformer.setOutputProperty("{<a class="moz-txt-link-freetext"
 href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
     if (encoding != null)<br>
     {<br>
       transformer.setOutputProperty(OutputKeys.ENCODING, encoding);<br>
     }<br>
     return transformer;<br>
   }</small><br>
 </blockquote>
 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...<br>
 <br>
 (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.)<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 #597752 is a reply to message #66491] | Sat, 11 March 2006 13:40  |  | 
| Eclipse User  |  |  |  |  | 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> </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?  The default XSD factory is registered via=20
 extension point, as follows.  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?  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> </DIV>
 <DIV><FONT face=3DArial size=3D2><extension=20
 point=3D"org.eclipse.emf.ecore.extension_parser"></FONT ></DIV>
 <DIV><FONT face=3DArial size=3D2>   <parser type=3D"xsd"=20
 class=3D"org.eclipse.xsd.util.XSDResourceFactoryImpl" /></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></extension></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>Thanks!</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>  Dave</FONT></DIV>
 <DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial=20
 size=3D2></FONT></FONT></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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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 15:31  |  | 
| Eclipse User  |  |  |  |  | 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" <merks@ca.ibm.com> =
 wrote in=20
 message news:duncnk$70q$1@utils.eclipse.org...<BR><BR>> So you could =
 override=20
 this and use the XSDResourceImpl.XSD_JAXP_CONFIG option to pass that in =
 during=20
 save.  If there's another magic property </FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>> value to add to the list, we can =
 do that=20
 too.  Please let me know how you solve this...</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial =
 size=3D2></FONT> </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).  Two changes are necessary</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>- add the Xerces specific =
 "indent-number" to=20
 the JAXP transformation factory</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2>   =20
 transformerFactory.setAttribute("indent-number", new =
 Integer(2));</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>- use a Writer instead of an=20
 OutputStream</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>I had been using =
 Resource.save(options), but that=20
 uses an outputstream.  So I wrote a simple utility class with a =
 static=20
 helper.  I asked about overriding the XSDResourceFactoryImpl, but =
 no longer=20
 need to do that.  But still interested in the best practice for=20
 this.</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>My solution looks like =
 this:</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>public class XSDResourceUtil =
 {</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2> public static void save(XSDSchema =
 schema, URI=20
 fileURI, ResourceSet resourceSet)<BR>   throws =
 IOException=20
 {<BR>  XSDResourceImpl resource =3D new=20
 XSDResourceImpl(fileURI);<BR>  resource.getContents().add(schem=
 a);<BR>   resourceSet.getResources().add(resource) ; </FONT></DIV>=
 
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  URIConverter uriConverter =
 =3D=20
 resourceSet.getURIConverter();<BR>  OutputStream outputStream =
 =3D=20
 uriConverter.createOutputStream(fileURI);<BR> <FONT=20
 color=3D#ff0000> Writer writer =3D new =
 OutputStreamWriter(outputStream,=20
 "utf-8");</FONT></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  Map options =3D new=20
 HashMap();<BR>  <STRONG><FONT=20
 color=3D#ff0000>options.put(XSDResourceImpl.XSD_JAXP_CONFIG, new=20
 XercesJAXPConfiguration());<BR></FONT></STRONG>  try=20
 {<BR>  <FONT color=3D#ff0000> resource.save(writer,=20
 options);<BR></FONT>  } finally=20
 {<BR>   writer.close();<BR>  } <BR> }</FONT>=
 </DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><BR><FONT face=3DArial size=3D2> private static class=20
 XercesJAXPConfiguration extends DefaultJAXPConfiguration {</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  public =
 XercesJAXPConfiguration()=20
 {<BR>   super();<BR>  } </FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>  public Transformer=20
 createTransformer(String encoding) throws TransformerException=20
 {<BR>   TransformerFactory transformerFactory =3D=20
 TransformerFactory.newInstance();<BR>    <BR>  <F=
 ONT=20
 color=3D#ff0000><STRONG> // workaround for JDK 1.5.0u6 and=20
 before<BR>    transformerFactory.setAttribut e( "indent-numbe=
 r", new=20
 Integer(2));<BR></STRONG></FONT>    <BR>   T=
 ransformer=20
 transformer =3D transformerFactory.newTransformer();</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial=20
 size=3D2>    transformer.setOutputProperty( OutputKeys.INDEN=
 T,=20
 "yes");<BR>    transformer.setOutputProperty( OutputKeys.MET=
 HOD,=20
 "xml");</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>   // Unless a width is =
 set, there=20
 will be only line breaks but no indentation.<BR>   // The =
 IBM JDK=20
 and the Sun JDK don't agree on the property =
 name,<BR>   // so we=20
 set them=20
 both.<BR>   //<BR>   transformer.setOutputP=
 roperty("{http://xml.apache.org/xalan}indent-amount",=20
 "2");<BR>    transformer.setOutputProperty( "{http://xml.apa=
 che.org/xslt}indent-amount",=20
 "2");<BR>   if (encoding !=3D null)=20
 {<BR>     transformer.setOutpu tProperty(OutputKeys.ENC=
 ODING,=20
 encoding);<BR>   }<BR>   return=20
 transformer;<BR>  }</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial =
 size=3D2> }<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 06:49  |  | 
| Eclipse User  |  |  |  |  | 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> </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?  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.</font></div>
 <div> </div>
 <div><font face="Arial" size="2"><extension
 point="org.eclipse.emf.ecore.extension_parser"></font ></div>
 <div><font face="Arial" size="2">   <parser type="xsd"
 class="org.eclipse.xsd.util.XSDResourceFactoryImpl" /></font></div>
 <div><font face="Arial" size="2"></extension></font></div>
 <div> </div>
 <div><font face="Arial" size="2">Thanks!</font></div>
 <div><font face="Arial" size="2">  Dave</font></div>
 <div> </div>
 <blockquote
 style="border-left: 2px solid rgb(0, 0, 0); padding-right: 0px; padding-left: 5px; margin-left: 5px; margin-right: 0px;">
 <div>"Ed Merks" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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 #597775 is a reply to message #66535] | Mon, 13 March 2006 07:16  |  | 
| Eclipse User  |  |  |  |  | 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>
   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"><merks@ca.ibm.com></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>
 > 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 </font></div>
 <div><font face="Arial" size="2">> value to add to the list, we
 can do that too.  Please let me know how you solve this...</font></div>
 <div> </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).  Two changes are necessary</font></div>
 <div><font face="Arial" size="2">- add the Xerces specific
 "indent-number" to the JAXP transformation factory</font></div>
 <div><font face="Arial" size="2">   
 transformerFactory.setAttribute("indent-number", new Integer(2));</font></div>
 <div> </div>
 <div><font face="Arial" size="2">- use a Writer instead of an
 OutputStream</font></div>
 <div> </div>
 <div><font face="Arial" size="2">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.</font></div>
 <div> </div>
 <div><font face="Arial" size="2">My solution looks like this:</font></div>
 <div> </div>
 <div><font face="Arial" size="2">public class XSDResourceUtil {</font></div>
 <div> </div>
 <div><font face="Arial" size="2"> public static void save(XSDSchema
 schema, URI fileURI, ResourceSet resourceSet)<br>
    throws IOException {<br>
   XSDResourceImpl resource = new XSDResourceImpl(fileURI);<br>
   resource.getContents().add(schema);<br>
   resourceSet.getResources().add(resource) ; </font></div>
 <div> </div>
 <div><font face="Arial" size="2">  URIConverter uriConverter =
 resourceSet.getURIConverter();<br>
   OutputStream outputStream = uriConverter.createOutputStream(fileURI);<br>
  <font color="#ff0000"> Writer writer = new
 OutputStreamWriter(outputStream, "utf-8");</font></font></div>
 <div> </div>
 <div><font face="Arial" size="2">  Map options = new HashMap();<br>
   <strong><font color="#ff0000">options.put(XSDResourceImpl.XSD_JAXP_CONFIG,
 new XercesJAXPConfiguration());<br>
 </font></strong>  try {<br>
   <font color="#ff0000"> resource.save(writer, options);<br>
 </font>  } finally {<br>
    writer.close();<br>
   }<br>
  }</font></div>
 <div> </div>
 <div><br>
 <font face="Arial" size="2"> private static class
 XercesJAXPConfiguration extends DefaultJAXPConfiguration {</font></div>
 <div> </div>
 <div><font face="Arial" size="2">  public XercesJAXPConfiguration() {<br>
    super();<br>
   }</font></div>
 <div> </div>
 <div><font face="Arial" size="2">  public Transformer
 createTransformer(String encoding) throws TransformerException {<br>
    TransformerFactory transformerFactory =
 TransformerFactory.newInstance();<br>
    <br>
   <font color="#ff0000"><strong> // workaround for JDK 1.5.0u6 and
 before<br>
    transformerFactory.setAttribut e( "indent-number", new Integer(2));<br>
 </strong></font>   <br>
    Transformer transformer = transformerFactory.newTransformer();</font></div>
 <div> </div>
 <div><font face="Arial" size="2">    transformer.setOutputProperty( OutputKeys.INDENT,
 "yes");<br>
    transformer.setOutputProperty( OutputKeys.METHOD, "xml");</font></div>
 <div> </div>
 <div><font face="Arial" size="2">   // Unless a width is set, there
 will be only line breaks but no indentation.<br>
    // The IBM JDK and the Sun JDK don't agree on the property name,<br>
    // so we set them both.<br>
    //<br>
    transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xalan">http://xml.apache.org/xalan</a>}indent-amount",
 "2");<br>
    transformer.setOutputProperty( "{<a class="moz-txt-link-freetext" href="http://xml.apache.org/xslt">http://xml.apache.org/xslt</a>}indent-amount",
 "2");<br>
    if (encoding != null) {<br>
     transformer.setOutpu tProperty(OutputKeys.ENCODING, encoding);<br>
    }<br>
    return transformer;<br>
   }</font></div>
 <div> </div>
 <div><font face="Arial" size="2"> }<br>
 }<br>
 </font></div>
 </blockquote>
 <br>
 </body>
 </html>
 
 --------------080704090600050406070604--
 |  |  |  |  | 
| Re: XSD indent serialization using JDK 1.5 [message #597780 is a reply to message #66578] | Mon, 13 March 2006 10:15  |  | 
| Eclipse User  |  |  |  |  | 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> </DIV>
 <DIV><FONT face=3DArial size=3D2>resource.save(options);</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </DIV>
 <DIV><FONT face=3DArial size=3D2>This method uses the resource URI to =
 write the=20
 file, but it always uses an OutputStream.  I need to study exactly =
 what the=20
 URIConverter does on the resource.save() implementation, and if it's =
 necessary=20
 in my case.  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? =20
 Could/should the resource.save(options) implementation use Writer =
 instead of=20
 OutputStream?</FONT></DIV>
 <DIV><FONT face=3DArial size=3D2></FONT> </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" <<A =
 href=3D"mailto:merks@ca.ibm.com">merks@ca.ibm.com</A>>=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>  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 10:26  |  | 
| Eclipse User  |  |  |  |  | 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.  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> </div>
 <div><font face="Arial" size="2">resource.save(options);</font></div>
 <div> </div>
 <div><font face="Arial" size="2">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?</font></div>
 <div> </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" <<a href="mailto:merks@ca.ibm.com">merks@ca.ibm.com</a>>
 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>
   public final void save(Writer writer, Map options) throws IOException<br>
 <br>
 Wouldn't that work?<br>
 </blockquote>
 </blockquote>
 <br>
 </body>
 </html>
 
 --------------080106090600090702010904--
 |  |  |  | 
 
 
 Current Time: Fri Oct 31 14:19:11 EDT 2025 
 Powered by FUDForum . Page generated in 0.06040 seconds |