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"><?xml version="
1.0" encoding="UTF-8"?><sld:NamedLayer
gml"><sld:UserStyle><sld:Name>Default Styler</
sld:Name><sld:Title>Default Styler</
sld:Title><sld:Abstract></
sld:Abstract><sld:FeatureTypeStyle><sld:FeatureTypeName>F
eature</
sld:FeatureTypeName><sld:Rule><sld:Name>name</
sld:Name><sld:Abstract>Abstract</
sld:Abstract><sld:Title>title</
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 > and <
...
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)