Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
de2fe096
Commit
de2fe096
authored
6 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-3967: try to use the XSLT transformer of the JDK (CXalan)
parent
a6024d20
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/ims/qti/render/LocalizedXSLTransformer.java
+21
-2
21 additions, 2 deletions
...java/org/olat/ims/qti/render/LocalizedXSLTransformer.java
with
21 additions
and
2 deletions
src/main/java/org/olat/ims/qti/render/LocalizedXSLTransformer.java
+
21
−
2
View file @
de2fe096
...
...
@@ -37,6 +37,7 @@ import javax.xml.transform.Source;
import
javax.xml.transform.Templates
;
import
javax.xml.transform.TransformerConfigurationException
;
import
javax.xml.transform.TransformerFactory
;
import
javax.xml.transform.TransformerFactoryConfigurationError
;
import
javax.xml.transform.sax.SAXSource
;
import
javax.xml.transform.stream.StreamResult
;
...
...
@@ -182,7 +183,7 @@ public class LocalizedXSLTransformer {
log
.
error
(
"Could not convert xsl to string!"
,
e
);
}
String
replacedOutput
=
evaluateValue
(
xslAsString
,
vcContext
);
TransformerFactory
tfactory
=
TransformerFactory
.
newInstance
();
TransformerFactory
tfactory
=
new
TransformerFactory
();
XMLReader
reader
;
try
{
reader
=
XMLReaderFactory
.
createXMLReader
();
...
...
@@ -195,6 +196,24 @@ public class LocalizedXSLTransformer {
throw
new
OLATRuntimeException
(
"Could not initialize transformer (wrong config)!"
,
e
);
}
}
/**
* The method try to find the Xalan implementation of the JDK because the styelsheet
* was with this one develop and not the Saxon XSLT 2.0 or 3.0 engine which lead to
* some compatibility issue with special HTML entity (example: 129).
*
* @return Try to get the embedded Xalan implementation which is a pure XSLT 1.0 engine.
*/
private
TransformerFactory
newTransformerFactory
()
{
TransformerFactory
tfactory
=
null
;
try
{
tfactory
=
TransformerFactory
.
newInstance
(
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"
,
null
);
}
catch
(
TransformerFactoryConfigurationError
e
)
{
log
.
error
(
""
,
e
);
tfactory
=
TransformerFactory
.
newInstance
();
}
return
tfactory
;
}
/**
* Takes String with template and fills values from Translator in Context
...
...
@@ -231,7 +250,7 @@ public class LocalizedXSLTransformer {
* @throws IOException
*/
private
static
String
slurp
(
InputStream
in
)
throws
IOException
{
StringBu
ff
er
out
=
new
StringBu
ff
er
();
StringBu
ild
er
out
=
new
StringBu
ild
er
();
byte
[]
b
=
new
byte
[
4096
];
for
(
int
n
;
(
n
=
in
.
read
(
b
))
!=
-
1
;)
{
out
.
append
(
new
String
(
b
,
0
,
n
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment