Package org.geotools.xml.styling
Class SLDParser
Object
SLDParser
Utility methods for working with SLD content.
- Author:
- jgarnett
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanSupport entity resolution expansion, defaultfalse.protected StyleFactoryprotected InputSourceprotected booleanSupport use of DOCTYPE DTD references, defaultfalse.protected booleanSupport validating , defaultfalse.protected booleanSupport XInclude , defaultfalse. -
Constructor Summary
ConstructorsConstructorDescriptionSLDParser(StyleFactory factory) Create a SLDParser - use if you already have a dom to parse.SLDParser(StyleFactory factory, File f) Creates a new SLDStyle object.SLDParser(StyleFactory factory, InputStream s) Creates a new SLDStyle object.SLDParser(StyleFactory factory, Reader r) Creates a new SLDStyle object.SLDParser(StyleFactory factory, String filename) Creates a new instance of SLDParser.SLDParser(StyleFactory factory, URL url) Creates a new SLDStyle object.SLDParser(StyleFactory factory, FilterFactory filterFactory) -
Method Summary
Modifier and TypeMethodDescriptionbooleanUse of validating is not required, and isfalseby default.booleanUse of XInclude is not recommended, and isfalseby default.booleanUse of expand entity references is not recommended, and isfalseby default.booleanUse of DTD is not recommended, and isfalseby default.protected DocumentBuildernewDocumentBuilder(boolean namespaceAware) Configured DocumentBuilder for parsing SLD documents, which requires namespace information.protected AnchorPointparseAnchorPoint(Node root) Internal method to parse an AnchorPoint node; protected visibility for testing.protected ChannelSelectionparseChannelSelection(Node root) Internal parse method - made protected for unit testingprotected ColorMapparseColorMap(Node root) Internal parse method - made protected for unit testingprotected ColorMapEntryparseColorMapEntry(Node root) Internal parse method - made protected for unit testingprotected ContrastEnhancementparseContrastEnhancement(Node root) Internal parse method - made protected for unit testingparseDescriptor(Node root) protected DisplacementparseDisplacement(Node root) Internal parse method - made protected for unit testingprotected ExternalGraphicparseExternalGraphic(Node root) Internal parse method - made protected for unit testingprotected FeatureTypeConstraintprotected FeatureTypeStyleparseFeatureTypeStyle(Node style) Internal parse method - made protected for unit testingprotected FillInternal parse method - made protected for unit testingprotected FilterparseFilter(Node child) Internal parse method - made protected for unit testingprotected FontInternal method to parse a Font Node; protected to allow for unit testingprotected ExpressionparseGeometry(Node root) Internal parse method - made protected for unit testingprotected StringparseGeometryName(Node root) Internal parse method - made protected for unit testingprotected GraphicparseGraphic(Node root) Internal parse method - made protected for unit testingprotected HaloInternal parse method - made protected for unit testingprotected LabelPlacementparseLabelPlacement(Node root) Internal parse method - made protected for unit testingprotected LinePlacementparseLinePlacement(Node root) Internal parse method - made protected for unit testingprotected LineSymbolizerparseLineSymbolizer(Node root) parses the SLD for a linesymbolizerprotected MarkInternal parse method - made protected for unit testingParses a NamedStyle from node.protected StringparseOnlineResource(Node root) Internal parse method - made protected for unit testingprotected OtherTextparseOtherText(Node root) protected PointPlacementparsePointPlacement(Node root) Internal parse method - made protected for unit testingprotected PointSymbolizerparsePointSymbolizer(Node root) parses the SLD for a point symbolizerprotected PolygonSymbolizerparsePolygonSymbolizer(Node root) parses the SLD for a polygonsymbolizerprotected RasterSymbolizerparseRasterSymbolizer(Node root) parses the SLD for a text symbolizerprotected RemoteOWSparseRemoteOWS(Node root) protected RuleInternal parse method - made protected for unit testingprotected SelectedChannelTypeparseSelectedChannel(Node root) Internal parse method - made protected for unit testingprotected ShadedReliefparseShadedRelief(Node root) Internal parse method - made protected for unit testingparseSLD()protected StrokeparseStroke(Node root) Internal parse method - made protected for unit testingparseStyle(Node n) build a style for the Node providedprotected TextSymbolizerparseTextSymbolizer(Node root) parses the SLD for a text symbolizerStyle[]readDOM()Read styles from the dom that was previously parsed.Style[]Read the DOM provided and create a Style object for each user style foundStyle[]readXML()Read the xml inputsource provided and create a Style object for each user style foundvoidsetEntityResolver(EntityResolver entityResolver) Sets the EntityResolver implementation that will be used by DocumentBuilder to resolve XML external entities.voidsetExpandEntityReferences(boolean expandEntityReferences) Use of expand entity references is not recommended, and isfalseby default.voidSets the file to use to read the SLD fromvoidsetInput(InputStream in) Sets the input stream to read the SLD fromvoidSets the input stream to read the SLD fromvoidset the file to read the SLD fromvoidsets an URL to read the SLD fromvoidsetOnLineResourceLocator(ResourceLocator onlineResourceLocator) Sets the resource loader implementation for parsing online resources.voidsetSupportDTD(boolean supportDTD) Use of DTD is not recommended, and isfalseby default.voidsetValidating(boolean validating) Use of validating is not required, and isfalseby default.voidsetXInclude(boolean xinclude) Use of XInclude is not recommended, and isfalseby default.
-
Field Details
-
source
-
factory
-
supportDTD
protected boolean supportDTDSupport use of DOCTYPE DTD references, defaultfalse. -
expandEntityReferences
protected boolean expandEntityReferencesSupport entity resolution expansion, defaultfalse. -
xinclude
protected boolean xincludeSupport XInclude , defaultfalse. -
validating
protected boolean validatingSupport validating , defaultfalse.
-
-
Constructor Details
-
SLDParser
Create a SLDParser - use if you already have a dom to parse.- Parameters:
factory- The StyleFactory to use to build the style
-
SLDParser
-
SLDParser
Creates a new instance of SLDParser.- Parameters:
factory- The StyleFactory to use to read the filefilename- The file to be read.- Throws:
FileNotFoundException- - if the file is missing
-
SLDParser
Creates a new SLDStyle object.- Parameters:
factory- The StyleFactory to use to read the filef- the File to be read- Throws:
FileNotFoundException- - if the file is missing
-
SLDParser
Creates a new SLDStyle object.- Parameters:
factory- The StyleFactory to use to read the fileurl- the URL to be read.- Throws:
IOException- - if something goes wrong reading the file
-
SLDParser
Creates a new SLDStyle object.- Parameters:
factory- The StyleFactory to use to read the files- The inputstream to be read
-
SLDParser
Creates a new SLDStyle object.- Parameters:
factory- The StyleFactory to use to read the filer- The inputstream to be read
-
-
Method Details
-
setInput
set the file to read the SLD from- Parameters:
filename- the file to read the SLD from- Throws:
FileNotFoundException- if the file is missing
-
setInput
Sets the file to use to read the SLD from- Parameters:
f- the file to use- Throws:
FileNotFoundException- if the file is missing
-
setInput
sets an URL to read the SLD from- Parameters:
url- the url to read the SLD from- Throws:
IOException- If anything goes wrong opening the url
-
setInput
Sets the input stream to read the SLD from- Parameters:
in- the inputstream used to read the SLD from
-
setInput
Sets the input stream to read the SLD from- Parameters:
in- the inputstream used to read the SLD from
-
setOnLineResourceLocator
Sets the resource loader implementation for parsing online resources. -
setEntityResolver
Sets the EntityResolver implementation that will be used by DocumentBuilder to resolve XML external entities. -
isSupportDTD
public boolean isSupportDTD()Use of DTD is not recommended, and isfalseby default. May be set to true if required for XML using DOCTYPE.- Returns:
falseto prevent support of DTD, ortrueif required.
-
setSupportDTD
public void setSupportDTD(boolean supportDTD) Use of DTD is not recommended, and isfalseby default.- Parameters:
supportDTD-falseto prevent support of DTD, if required for XML using DOCTYPE.
-
isExpandEntityReferences
public boolean isExpandEntityReferences()Use of expand entity references is not recommended, and isfalseby default. May be set to true DOCTYPE is used to define injected entities.- Returns:
falseto prevent support of expanding entity references, ortrueif required.
-
setExpandEntityReferences
public void setExpandEntityReferences(boolean expandEntityReferences) Use of expand entity references is not recommended, and isfalseby default. May be set totrueif DOCTYPE is used to to define references.- Parameters:
expandEntityReferences- Usefalseto prevent support of expanding entity references, ortrueif required.
-
setXInclude
public void setXInclude(boolean xinclude) Use of XInclude is not recommended, and isfalseby default. May be set totrueto support inclusion of xsd content.- Parameters:
xinclude- Usefalseto prevent use of XInclude, ortrueif required.
-
getXInclude
public boolean getXInclude()Use of XInclude is not recommended, and isfalseby default. May be set totrueto support inclusion of xsd content.- Returns:
- Use
falseto prevent use of XInclude, ortrueif required.
-
setValidating
public void setValidating(boolean validating) Use of validating is not required, and isfalseby default. Use of validating,- Parameters:
validating- Usefalseto parse document without validation, ortrueto validate usingXMLConstants.W3C_XML_SCHEMA_NS_URI.
-
getValidating
public boolean getValidating()Use of validating is not required, and isfalseby default.- Returns:
- Use
falseto parse document without validation, ortrueto validate usingXMLConstants.W3C_XML_SCHEMA_NS_URI.
-
newDocumentBuilder
protected DocumentBuilder newDocumentBuilder(boolean namespaceAware) throws ParserConfigurationException Configured DocumentBuilder for parsing SLD documents, which requires namespace information.- Parameters:
namespaceAware-- Returns:
- Throws:
ParserConfigurationException
-
readXML
Read the xml inputsource provided and create a Style object for each user style found- Returns:
- Style[] the styles constructed.
- Throws:
RuntimeException- if a parsing error occurs
-
readDOM
Read styles from the dom that was previously parsed. -
readDOM
Read the DOM provided and create a Style object for each user style found- Parameters:
document- a dom containing the SLD- Returns:
- Style[] the styles constructed.
-
parseSLD
-
parseDescriptor
-
parseFeatureTypeConstraint
-
parseRemoteOWS
-
parseNamedStyle
Parses a NamedStyle from node.A NamedStyle is used to refer to a style that has a name in a WMS, and is defined as:
<code> <xsd:element name="NamedStyle"> <xsd:annotation> <xsd:documentation> A NamedStyle is used to refer to a style that has a name in a WMS. </xsd:documentation> </xsd:annotation> <xsd:complexType> <xsd:sequence> <xsd:element ref="sld:Name"/> </xsd:sequence> </xsd:complexType> </xsd:element> </code> -
parseStyle
build a style for the Node provided- Parameters:
n- the node which contains the style to be parsed.- Returns:
- the Style constructed.
- Throws:
RuntimeException- if an error occurs setting up the parser
-
parseFeatureTypeStyle
Internal parse method - made protected for unit testing -
parseRule
Internal parse method - made protected for unit testing -
parseFilter
Internal parse method - made protected for unit testing -
parseLineSymbolizer
parses the SLD for a linesymbolizer- Parameters:
root- a w2c Dom Node- Returns:
- the linesymbolizer
-
parsePolygonSymbolizer
parses the SLD for a polygonsymbolizer- Parameters:
root- w3c dom node- Returns:
- the polygon symbolizer
-
parseTextSymbolizer
parses the SLD for a text symbolizer- Parameters:
root- w3c dom node- Returns:
- the TextSymbolizer
-
parseOtherText
-
parseRasterSymbolizer
parses the SLD for a text symbolizer- Parameters:
root- w3c dom node- Returns:
- the TextSymbolizer
-
parseColorMapEntry
Internal parse method - made protected for unit testing -
parseColorMap
Internal parse method - made protected for unit testing -
parseSelectedChannel
Internal parse method - made protected for unit testing -
parseChannelSelection
Internal parse method - made protected for unit testing -
parseContrastEnhancement
Internal parse method - made protected for unit testing -
parseShadedRelief
Internal parse method - made protected for unit testing -
parsePointSymbolizer
parses the SLD for a point symbolizer- Parameters:
root- a w3c dom node- Returns:
- the pointsymbolizer
-
parseGraphic
Internal parse method - made protected for unit testing -
parseGeometryName
Internal parse method - made protected for unit testing -
parseGeometry
Internal parse method - made protected for unit testing -
parseMark
Internal parse method - made protected for unit testing -
parseExternalGraphic
Internal parse method - made protected for unit testing -
parseOnlineResource
Internal parse method - made protected for unit testing -
parseStroke
Internal parse method - made protected for unit testing -
parseFill
Internal parse method - made protected for unit testing -
parseFont
Internal method to parse a Font Node; protected to allow for unit testing -
parseLabelPlacement
Internal parse method - made protected for unit testing -
parsePointPlacement
Internal parse method - made protected for unit testing -
parseLinePlacement
Internal parse method - made protected for unit testing -
parseAnchorPoint
Internal method to parse an AnchorPoint node; protected visibility for testing. -
parseDisplacement
Internal parse method - made protected for unit testing -
parseHalo
Internal parse method - made protected for unit testing
-