- java.lang.Object
-
- javax.xml.transform.sax.SAXSource
-
- All Implemented Interfaces:
- Source
- Direct Known Subclasses:
- JAXBSource
public class SAXSource extends Object implements Source
Acts as an holder for SAX-style Source.
Note that XSLT requires namespace support. Attempting to transform an input source that is not generated with a namespace-aware parser may result in errors. Parsers can be made namespace aware by calling the
SAXParserFactory.setNamespaceAware(boolean awareness)
method.
-
-
Field Summary
Fields Modifier and Type Field and Description static String
FEATURE
IfTransformerFactory.getFeature(java.lang.String)
returns true when passed this value as an argument, the Transformer supports Source input of this type.
-
Constructor Summary
Constructors Constructor and Description SAXSource()
Zero-argument default constructor.SAXSource(InputSource inputSource)
Create aSAXSource
, using a SAXInputSource
.SAXSource(XMLReader reader, InputSource inputSource)
Create aSAXSource
, using anXMLReader
and a SAX InputSource.
-
Method Summary
Methods Modifier and Type Method and Description InputSource
getInputSource()
Get the SAX InputSource to be used for the Source.String
getSystemId()
Get the base ID (URI or system ID) from where URIs will be resolved.XMLReader
getXMLReader()
Get the XMLReader to be used for the Source.void
setInputSource(InputSource inputSource)
Set the SAX InputSource to be used for the Source.void
setSystemId(String systemId)
Set the system identifier for this Source.void
setXMLReader(XMLReader reader)
Set the XMLReader to be used for the Source.static InputSource
sourceToInputSource(Source source)
Attempt to obtain a SAX InputSource object from a Source object.
-
-
-
Field Detail
-
FEATURE
public static final String FEATURE
IfTransformerFactory.getFeature(java.lang.String)
returns true when passed this value as an argument, the Transformer supports Source input of this type.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SAXSource
public SAXSource()
Zero-argument default constructor. If this constructor is used, and no SAX source is set using
setInputSource(InputSource inputSource)
, then theTransformer
will create an empty sourceInputSource
usingnew InputSource()
.
-
SAXSource
public SAXSource(XMLReader reader, InputSource inputSource)
Create aSAXSource
, using anXMLReader
and a SAX InputSource. TheTransformer
orSAXTransformerFactory
will set itself to be the reader'sContentHandler
, and then will call reader.parse(inputSource).- Parameters:
reader
- An XMLReader to be used for the parse.inputSource
- A SAX input source reference that must be non-null and that will be passed to the reader parse method.
-
SAXSource
public SAXSource(InputSource inputSource)
Create aSAXSource
, using a SAXInputSource
. TheTransformer
orSAXTransformerFactory
creates a reader viaXMLReaderFactory
(if setXMLReader is not used), sets itself as the reader'sContentHandler
, and calls reader.parse(inputSource).- Parameters:
inputSource
- An input source reference that must be non-null and that will be passed to the parse method of the reader.
-
-
Method Detail
-
setXMLReader
public void setXMLReader(XMLReader reader)
Set the XMLReader to be used for the Source.- Parameters:
reader
- A valid XMLReader or XMLFilter reference.
-
getXMLReader
public XMLReader getXMLReader()
Get the XMLReader to be used for the Source.- Returns:
- A valid XMLReader or XMLFilter reference, or null.
-
setInputSource
public void setInputSource(InputSource inputSource)
Set the SAX InputSource to be used for the Source.- Parameters:
inputSource
- A valid InputSource reference.
-
getInputSource
public InputSource getInputSource()
Get the SAX InputSource to be used for the Source.- Returns:
- A valid InputSource reference, or null.
-
setSystemId
public void setSystemId(String systemId)
Set the system identifier for this Source. If an input source has already been set, it will set the system ID or that input source, otherwise it will create a new input source.The system identifier is optional if there is a byte stream or a character stream, but it is still useful to provide one, since the application can use it to resolve relative URIs and can include it in error messages and warnings (the parser will attempt to open a connection to the URI only if no byte stream or character stream is specified).
- Specified by:
setSystemId
in interfaceSource
- Parameters:
systemId
- The system identifier as a URI string.
-
getSystemId
public String getSystemId()
Get the base ID (URI or system ID) from where URIs will be resolved.
- Specified by:
getSystemId
in interfaceSource
- Returns:
- Base URL for the
Source
, ornull
.
-
sourceToInputSource
public static InputSource sourceToInputSource(Source source)
Attempt to obtain a SAX InputSource object from a Source object.- Parameters:
source
- Must be a non-null Source reference.- Returns:
- An InputSource, or null if Source can not be converted.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
18/12/2024 16:46:36 Cette version de la page est en cache (à la date du 18/12/2024 16:46:36) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 31/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/xml/transform/sax/saxsource.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.