问题
I am new to jaxp and has no idea of using the above static fields and what they mean ?
Need its explanation along with examples.
Thanks in advance
回答1:
XSLT has a feature called "disable output escaping" that tells the serializer to output <a>
as <a>
whereas it would normally output <a>
. This is a hack that is best avoided, for many reasons, one of which is that it requires a special side-channel for the transformation engine to communicate with the serializer (so the transformer can tell the serializer to switch doe on and off).
In JAXP, to allow one vendor's transformation engine to talk to another vendor's serializer, the protocol for passing these doe-on and doe-off requests is this pair of processing instructions.
You don't need this feature and you can safely ignore its existence. Never be tempted to imagine that just because a feature is there, you must be missing something if you never use it.
回答2:
(Disclaimer - I maintain the JDOM XML Library) - These PI's (ProcessingInstructions) are designed to indicate to XML outputting programs that they should break compatibility with the XML standard, and produce invalid XML.
Under certain conditions, this can be useful.
Here is a test-case in the JDOM test harness. It basically has input like (I have added some whitepsace to it to make it easier to see):
<root>
&
<?javax.xml.transform.disable-output-escaping ?>
&&
<?javax.xml.transform.enable-output-escaping ?>
&
</root>
In the above example, we have valid XML. If you were to process this data through a system that recognizes the processing instrucitons, it should output (something like)
<root>
&
&&
&
</root>
Note that this is no longer valid XML..... the & characters between the PI's have not been escaped correctly.
From a JDOM perspective, this is documented here in the javadoc
These instructions are normally used in XML Transformations to produce output that is 'pretty, and is not consumed by machines, but by people. Use it with caution.
Hope that gives you some insight.... all the best.
来源:https://stackoverflow.com/questions/16400200/what-is-the-use-of-static-fields-pi-enable-output-escaping-pi-disable-output-e