Permalink
Browse files

Update CSS processor interface to allow stylesheet URIs

  • Loading branch information...
ndw committed Sep 6, 2015
1 parent ab04076 commit 72824e259e97715628a35baceb3de0420438a5fc
@@ -17,5 +17,6 @@
public interface CssProcessor {
public void initialize(XProcRuntime runtime, XStep step, Properties options);
public void addStylesheet(XdmNode doc);
+ public void addStylesheet(String uri);
public void format(XdmNode doc, OutputStream out, String contentType);
}
@@ -39,6 +39,7 @@
public class CssFormatter extends DefaultStep {
private static final QName _href = new QName("","href");
+ private static final QName _css = new QName("","css");
private static final QName _content_type = new QName("","content-type");
private ReadablePipe source = null;
private ReadablePipe css = null;
@@ -90,7 +91,7 @@ public void run() throws SaxonApiException {
throw new XProcException(step.getNode(), "Failed to instantiate CSS provider");
}
- while (css.moreDocuments()) {
+ while (css != null && css.moreDocuments()) {
XdmNode style = css.read();
provider.addStylesheet(style);
}
@@ -102,6 +103,13 @@ public void run() throws SaxonApiException {
contentType = "application/pdf";
}
+ if (getOption(_css) != null) {
+ String s = getOption(_css).getString();
+ for (String css : s.split("\\s+")) {
+ provider.addStylesheet(css);
+ }
+ }
+
String href = getOption(_href).getString();
String base = getOption(_href).getBaseURI().toASCIIString();

0 comments on commit 72824e2

Please sign in to comment.