Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Dumping Style into file

I was having a similar problem with the FidFilter getting encoded incorrectly in XML. I sent an email to the geotools-devel list, so hopefully it will be resolved soon. If you would like, I can forward that thread to you so you can see exactly the problem I am having.

Cole

On 9/19/05, divol <divol@xxxxxxxx> wrote:
a rapid answer (i am meetining today ..)


Just creating my Style (with a huge amount of Like Rules) et showing it inti the style editor throw an exception.

Unable to create view: org.xml.sax.SAXParseException: Element type "ogc:PropertyIsLike" must be followed by either attribute specifications, ">" or "/>".

just bevauce the SLDContent.save used 

momento.putTextData(out);


where out is a XML filebuffer with (<,>) but transformed to &lg; ...

i'll test later the getString on the memento but if it work it's just work around fix  (i am affraid)


jacques divol


Le 16 sept. 05 à 19:19, jeichar@xxxxxxxxxxxxxxx a écrit :

I beleive that if you install udig (a normal version) you can download a
extension using the update manager (under help) that exports the style of a
layer to a file.  The code can be found in the repository under community/jesse
I believe.

As for what you are doing wrong and how we should be doing it right.... I'm not
100% sure to be perfectly honest with you.   What happens if you do a getString
on the momento?  does it change the < and  > back?

Jesse

Quoting divol < divol@xxxxxxxx>:


hello,

In order to have a look to sld xml file, I did that :


  public static void dumpStyle(Style style,Writer writer )
     {

         if (writer == null)
         {
             dumpStyle(style);
             return;
         }
         SLDContent styleContent = new SLDContent();
         try {
         // save the state of the style
         XMLMemento memento = XMLMemento.createWriteRoot
("styleEntry"); //$NON-NLS-1$
         styleContent.save(memento, style);
         memento.save(writer);
         writer.close ();

     } catch (IOException e) {
         System.out.println(  "dumpStyle");
         e.printStackTrace();

     }
     }


and that
  public static void dumpStyle(Style style )
     {
         SLDContent styleContent = new SLDContent();
     try {

         // save the state of the sty                                le

         XMLMemento memento = XMLMemento.createWriteRoot
("styleEntry"); //$NON-NLS-1$

         styleContent.save(memento, style);



         StringWriter writer = new StringWriter();

         memento.save(writer);

      System.out.println(  writer.getBuffer().toString());



         writer.close();

     } catch (IOException e) {
         System.out.println(  "dumpStyle");
         e.printStackTrace();

     }
     }


the result (the begining of the file) is :


<?xml version=" 1.0" encoding="UTF-8"?>
<styleEntry type="SLDStyle" version="1.0">&lt;?xml version=&quot;
1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;sld:NamedLayer
xmlns:gml=&quot; http://www.opengis.net/
gml&quot;&gt;&lt;sld:UserStyle&gt;&lt;sld:Name&gt;Default Styler&lt;/
sld:Name&gt;&lt;sld:Title&gt;Default Styler&lt;/
sld:Title&gt;&lt;sld:Abstract&gt;&lt;/
sld:Abstract&gt;&lt;sld:FeatureTypeStyle&gt;&lt;sld:FeatureTypeName&gt;F
eature&lt;/
sld:FeatureTypeName&gt;&lt;sld:Rule&gt;&lt;sld:Name&gt;name&lt;/
sld:Name&gt;&lt;sld:Abstract&gt;Abstract&lt;/
sld:Abstract&gt;&lt;sld:Title&gt;title&lt;/



not a good result definitly...


i tried to understand why and fall into SLDContent :

public void save( IMemento momento, Object value ) {
         Style style = (Style) value;

         // serialize out the style objects
         SLDTransformer sldWriter = new SLDTransformer();
         String out = ""; //$NON-NLS-1$
         try {
             out = sldWriter.transform (style);
         } catch (TransformerException e) {
             SLDPlugin.log(null, e);
             e.printStackTrace();
         } catch (Exception e) {
             SLDPlugin.log(null, e);
         }
         momento.putTextData(out);
         momento.putString("type", "SLDStyle"); //$NON-NLS-1$ //$NON-
NLS-2$
         momento.putString("version", "1.0"); //$NON-NLS-1$ //$NON-
NLS-2$
     }


when you use
-momento.putTextData (out);

with an XMLMemento, the DOMWriter use getEscaped() function if it
crosses a TEXT element
so the < and the > are trashed into &gt; and &lt;
...

As a side effect when i open the style editor i got this eerror :
Unable to create view: org.xml.sax.SAXParseException: Element type
"ogc:PropertyIsLike" must be followed by either attribute
specifications, ">" or "/>".

with

org.xml.sax.SAXParseException: Element type "ogc:PropertyIsLike" must
be followed by either attribute specifications, ">" or "/>".
     at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse
(DOMParser.java:264)
     at
com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse
(DocumentBuilderImpl.java:292)
     at org.geotools.styling.SLDParser.readXML(SLDParser.java:224)
     at net.refractions.udig.style.sld.SLDContent.load
(SLDContent.java:126)
     at
net.refractions.udig.project.internal.impl.StyleBlackboardImpl.getObject
(StyleBlackboardImpl.java:152)
     at
net.refractions.udig.project.internal.impl.StyleBlackboardImpl.get
(StyleBlackboardImpl.java:112)
     at org.hybam.cash.udig.style.StyledPalette.getSLD
(StyledPalette.java:136)
     at org.hybam.cash.udig.style.StyledPalette.refresh
(StyledPalette.java:152)
     at net.refractions.udig.style.IStyleConfigurator.focus
(IStyleConfigurator.java:287)
     at net.refractions.udig.style.ui.StyleView$StyleViewSite.focus
(StyleView.java:916)
     at net.refractions.udig.style.ui.StyleView.setStyleConfigurator
(StyleView.java:522)
     at net.refractions.udig.style.ui.StyleView.setCurrentLayer
(StyleView.java:348)
     at net.refractions.udig.style.ui.StyleView$1.selectionChanged
(StyleView.java:153)
     at net.refractions.udig.style.ui.StyleView.createPartControl
(StyleView.java:306)
     at org.eclipse.ui.internal.ViewReference.createPartHelper
(ViewReference.java:305)
     at org.eclipse.ui.internal.ViewReference.createPart
(ViewReference.java:180)
     at org.eclipse.ui.internal.WorkbenchPartReference.getPart
(WorkbenchPartReference.java:552)
     at org.eclipse.ui.internal.Perspective.showView (Perspective.java:
1655)
     at org.eclipse.ui.internal.WorkbenchPage.busyShowView
(WorkbenchPage.java:930)
     at org.eclipse.ui.internal.WorkbenchPage.access$12
(WorkbenchPage.java:913)
     at org.eclipse.ui.internal.WorkbenchPage$13.run
(WorkbenchPage.java:3148)
     at org.eclipse.swt.custom.BusyIndicator.showWhile
(BusyIndicator.java:69)
     at org.eclipse.ui.internal.WorkbenchPage.showView
(WorkbenchPage.java:3145)
     at org.eclipse.ui.internal.WorkbenchPage.showView
(WorkbenchPage.java:3123)
     at net.refractions.udig.style.ui.EditStyleAction$1.run
(EditStyleAction.java:35)
     at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
     at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages
(Synchronizer.java:123)
     at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:
2932)
     at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:
2708)
     at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java :
1699)
     at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
     at org.eclipse.ui.internal.Workbench.createAndRunWorkbench
(Workbench.java:367)
     at org.eclipse.ui.PlatformUI.createAndRunWorkbench
(PlatformUI.java:143)
     at net.refractions.udig.internal.ui.UDIGApplication.run
(UDIGApplication.java:28)
     at org.eclipse.core.internal.runtime.PlatformActivator$1.run
(PlatformActivator.java:226)
     at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:376)
     at org.eclipse.core.runtime.adaptor.EclipseStarter.run
(EclipseStarter.java:163)
     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
     at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
     at org.eclipse.core.launcher.Main.run(Main.java:973)
     at org.eclipse.core.launcher.Main.main(Main.java:948)




where is my mistake ??? working on MacOs Tiger ?? ;p)


of course the style (260 kb xml file ) is well drawned on the
screen ....  (tiff mac format)


jacques divol
cash-espace-ird













_______________________________________________
User-friendly Desktop Internet GIS (uDig)



_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel




Back to the top