[
http://issues.apache.org/jira/browse/XALANJ-2264?page=comments#action_12368148
]
Brian Minchau commented on XALANJ-2264:
---------------------------------------
There is a -FLAVOR command line options for the org.apache.xalan.xslt.Process
main method.
Right after this option is the flavor which can be one three values:
"s2s" (the default value)
"d2d"
"th"
The "d2d" option means that the stylesheet itself is a DOM. This block of code
in
org.apache.xalan.xslt.Process can be modified (as already seen in Rudolf
Weber's patch:
if (flavor.equals("d2d"))
{
// Parse in the xml data into a DOM
DocumentBuilderFactory dfactory =
DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
if (isSecureProcessing)
{
try
{
dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
true);
}
catch (ParserConfigurationException pce) {}
}
DocumentBuilder docBuilder = dfactory.newDocumentBuilder();
Node xslDOM = docBuilder.parse(new InputSource(xslFileName));
stylesheet = tfactory.newTemplates(new DOMSource(xslDOM,
xslFileName));
}
It already sets a feature and namespace awareness of the DocumentBuilderFactory.
The else case of the block above, when the flavor is not "d2d" is more
troublesome:
else
{
// System.out.println("Calling newTemplates: "+xslFileName);
stylesheet = tfactory.newTemplates(new StreamSource(xslFileName));
// System.out.println("Done calling newTemplates: "+xslFileName);
}
A StreamSource is presented to the TransformerFactory newTemplates method.
Inside of that method is this code which can be exercised:
===============================================================
javax.xml.parsers.SAXParserFactory factory =
javax.xml.parsers.SAXParserFactory.newInstance();
factory.setNamespaceAware(true);
if (m_isSecureProcessing)
{
try
{
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
}
catch (org.xml.sax.SAXException se) {}
}
javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();
reader = jaxpParser.getXMLReader();
==============================================================
So it looks like we need to transfer options parsed in Process to
TransformerFactoryImpl
The one method that does so is TransformerFactory.setFeature(String s, boolean
b) but in
currently only handles the 'secure' feature.
Likewise this class might use TransformerIdentityImpl which also has a
constructor that
takes this 'secure' boolean. So some work is needed here to support other
features.
Besides XInclude, there are plenty of other factory features.
I was thinking of something like a command line -XMLPARSER option, e.g.
org.apache.xalan.xslt.Process -XMLPARSER setFeature(someNewFeature,true) -IN
a.xml -XSL a.xsl
or for XINclude use -XMLPARSER setXIncludeAware(true)
Through Java reflection the method name could be obtained, and the args
obtained.
Other suggestions on a flexible API to set the factory features?
This work is not so easy. Can anyone give a more comprehensive patch? One
that
sets the features of the DocumentBuilderFactory/SAXParserFactory in all
situations?
> Supporting xi:include on xalan command-line
> -------------------------------------------
>
> Key: XALANJ-2264
> URL: http://issues.apache.org/jira/browse/XALANJ-2264
> Project: XalanJ2
> Type: New Feature
> Components: Xalan-CmdLine
> Versions: Latest Development Code
> Environment: all
> Reporter: Rudolf Weber
> Attachments: xalan-xi.patch.txt
>
> The xi:include-awareness should be specifiable on the command-line.
> The default is on, since I think in the normal case it is useful.
> In the special case, the default has to be swiched off with -NIA.
> (Of course, it may be good keep the current behavior on default. I think,
> that the xi:include is not in wide use, so I want to risk to change the
> default. )
> In our project we want to include declarations in a programming language
> in the xslt-file, so the option -XSLIA.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]