Skip to content

Commit

Permalink
Update CSS processor interface to allow stylesheet URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
ndw committed Sep 6, 2015
1 parent ab04076 commit 72824e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/xmlcalabash/config/CssProcessor.java
Expand Up @@ -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);
}
10 changes: 9 additions & 1 deletion src/main/java/com/xmlcalabash/extensions/CssFormatter.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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();

Expand Down

0 comments on commit 72824e2

Please sign in to comment.