3.1 Shift_JIS Switch Function
The Shift_JIS switch function changes the character encoding applied by Cosminexus XML Processor to SJIS (x-sjis-jdk1.1.7) or MS932 (x-sjis-cp932) when the encoding attribute in the XML document specifies Shift_JIS. The following table lists the correspondence between the encoding specifications for an XML document and the applicable character encodings.
- Legend:
-
--: Cannot be specified
The Shift_JIS switch function is specified by setting a certain property to the instance of the XML parser or XSLT transformer. For details about how to set properties, see 4.5 How to use the properties of the Shift_JIS switch function.
The encoding specification using the Shift_JIS switch function is applied to the following items. The encoding cannot be applied to other items.
-
encoding attribute of an input XML document
-
Encoding specified for the InputSource object
-
The output character stream when Shift_JIS is specified with the encoding attribute of the xsl:output element in the stylesheet or the setOutputProperty and setOutputProperties methods of the javax.xml.transform.Transformer class.
Care is required in the following cases:
-
When the InputSource object is specified as the InputSource for DOM and SAX parsers:
The Shift_JIS switch function is disabled if encoding other than Shift_JIS is specified for the InputSource object. In addition, when Reader is specified for the InputSource object, the Shift_JIS switch function is also disabled and the encoding being used by the Reader is applied.
-
When the StreamSource object is specified as the input source for the XSLT or XSLTC transformer:
When Reader is specified for the StreamSource object, the Shift_JIS switch function is disabled and the encoding being used by the Reader is applied.
-
When the DOMSource object is specified as the input source for the XSLT or XSLTC transformer:
The XML document has already undergone character code conversion when the DOMSource was generated. The Shift_JIS switch function is therefore disabled.
To enable the Shift_JIS switch function, you need to specify the Shift_JIS switch function in advance so the parser is used for generating the DOM node for the DOMSource.
-
When the SAXSource object is specified as the input source for the XSLT or XSLTC transformer:
If the InputSource object is specified for the SAXSource object, caution must be exercised for case 1 above. If the XMLReader object is specified for the SAXSource object, the Shift_JIS switch function specified in XMLReader is valid.
-
The JAXB does not support the Shift_JIS switch functionality when the Node, Source, or Result that is created either by the DOM parser or SAX parser where the Shift_JIS switch functionality is specified, is passed as an argument of the APIs of JAXB.
-
StAX does not support the Shift_JIS switch functionality. Therefore, for input and output of XSLT or the XSLTC transformer, if anyone of the following is used, the operation will not be guaranteed:
-
StAXSource
-
StAXResult
-