Permalink
Browse files

Hack XInclude to support fragid attribute (more work needed for prope…

…r XInclude 1.1 support)
  • Loading branch information...
ndw committed Sep 20, 2013
1 parent a5254b2 commit 9a3fa96bd286ac710ca7b2c537d2175462018f12
Showing with 9 additions and 3 deletions.
  1. +9 −3 src/com/xmlcalabash/library/XInclude.java
@@ -22,15 +22,13 @@
import java.util.Stack;
import java.util.Hashtable;
import java.util.Vector;
-import java.util.Iterator;
import java.util.HashSet;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.URISyntaxException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.xmlcalabash.io.ReadablePipe;
@@ -59,6 +57,7 @@
private static final QName _encoding = new QName("", "encoding");
private static final QName _href = new QName("", "href");
private static final QName _parse = new QName("", "parse");
+ private static final QName _fragid = new QName("", "fragid");
private static final QName _xpointer = new QName("", "xpointer");
private static final Pattern linesXptrRE = Pattern.compile("\\s*lines\\s*\\(\\s*(\\d+)\\s*-\\s*(\\d+)\\s*\\)\\s*");
@@ -152,13 +151,20 @@ public boolean processStartElement(XdmNode node) throws SaxonApiException {
String xptr = node.getAttributeValue(_xpointer);
XPointer xpointer = null;
XdmNode subdoc = null;
+ boolean textfragok = runtime.getAllowXPointerOnText();
+
+ /* HACK */
+ if ("text".equals(parse) && node.getAttributeValue(_fragid) != null) {
+ xptr = "text(" + node.getAttributeValue(_fragid) + ")";
+ textfragok = true;
+ }
if (xptr != null) {
xpointer = new XPointer(xptr);
}
if ("text".equals(parse)) {
- if (!runtime.getAllowXPointerOnText() && xpointer != null) {
+ if (!textfragok && xpointer != null) {
throw XProcException.stepError(1, "XPointer is not allowed on XInclude when parse='text'");
}

0 comments on commit 9a3fa96

Please sign in to comment.