@Override public int allocate(String prefix, short uriCode, String localName) { CacheKey key = new CacheKey(prefix, uriCode, localName); Integer code = nameCodes.get(key); if(code == null) { code = super.allocate(prefix, uriCode, localName); nameCodes.putIfAbsent(key, code); } return code; }
@Override public short allocateCodeForURI(String uri) { Short code = uriCodes.get(uri); if(code == null) { code = super.allocateCodeForURI(uri); uriCodes.putIfAbsent(uri, code); } return code; }
@Override public int allocateNamespaceCode(int namecode) { Integer code = nameToNamespaceCodes.get(namecode); if(code == null) { code = super.allocateNamespaceCode(namecode); nameToNamespaceCodes.putIfAbsent(namecode, code); } return code; }
/** <p>Constructor for the UnwrapLinksEmitter.</p> * * @param namePool The name pool to use for constructing elements and attributes. * @param foStylesheet Is this an FO stylesheet? */ public UnwrapLinksEmitter(Controller controller, NamePool namePool, boolean foStylesheet) { super(controller,namePool); elementStack = new Stack(); this.foStylesheet = foStylesheet; htmlAFingerprint = namePool.getFingerprint("", "a"); xhtmlAFingerprint = namePool.getFingerprint(xhURI, "a"); }
private String getShortMode(Context context) { String modeName=""; Mode mode = context.getMode(); if (mode!=null && mode.getNameCode()!=-1) { modeName=context.getController().getNamePool().getDisplayName(mode.getNameCode()); if(format==Format.COMPRESSED) { Integer value=namePool.get(modeName); if(value==null) { value=namePool.size(); namePool.put(modeName, value); } modeName=value.toString(); } } return modeName; }
public Document createInternalDOM(Source input) throws TransformerException { //use internal Saxon API instead of identity transformation //to preserve line numbers if SAXSource is available if(input instanceof SAXSource){ TinyBuilder builder = new TinyBuilder(); builder.setLineNumbering(true); builder.setNamePool(NamePool.getDefaultNamePool()); return (Document)builder.build((SAXSource)input); } else { Transformer trans = Xslt.createIdentityTransformer(XsltVersion.XSLT1); ((Controller)trans).setLineNumbering(true); DOMResult result = new DOMResult(); trans.transform(input, result); return (Document)result.getNode(); } }
int thisFingerprint = namePool.getFingerprint(nameCode); int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); int htmlPreFingerprint = namePool.getFingerprint("", "pre"); int htmlDivFingerprint = namePool.getFingerprint("", "div"); int xhtmlPreFingerprint = namePool.getFingerprint(xhURI, "pre"); int xhtmlDivFingerprint = namePool.getFingerprint(xhURI, "div");
public void endSpan(Emitter rtf) throws TransformerException { if (!foStylesheet && namePool != null) { if (xhStylesheet) { uri = xhURI; } int spanName = namePool.allocate("", uri, "span"); rtf.endElement(spanName); } }
int thisFingerprint = namePool.getFingerprint(nameCode); int foBlockFingerprint = namePool.getFingerprint(foURI, "block"); int htmlPreFingerprint = namePool.getFingerprint("", "pre"); int htmlDivFingerprint = namePool.getFingerprint("", "div"); int xhtmlPreFingerprint = namePool.getFingerprint(xhURI, "pre"); int xhtmlDivFingerprint = namePool.getFingerprint(xhURI, "div");
@Override public int allocateNamespaceCode(String prefix, String uri) { CacheKey key = new CacheKey(prefix, uri); Integer code = namespaceCodes.get(key); if(code == null) { code = super.allocateNamespaceCode(prefix, uri); namespaceCodes.putIfAbsent(key, code); } return code; }
public void startSpan(Emitter rtf, String id) throws TransformerException { if (!foStylesheet && namePool != null) { if(xhStylesheet) { uri = xhURI; } int spanName = namePool.allocate("", uri, "span"); AttributeCollection spanAttr = new AttributeCollection(namePool); int namespaces[] = new int[1]; spanAttr.addAttribute("", uri, "class", "CDATA", "co"); spanAttr.addAttribute("", uri, "id", "CDATA", id); rtf.startElement(spanName, spanAttr, namespaces, 0); } }
throws TransformerException { int thisFingerprint = namePool.getFingerprint(nameCode); int colFingerprint = namePool.getFingerprint("", "col"); int XHTMLcolFingerprint = namePool.getFingerprint(xhtmlURI, "col"); int foColFingerprint = namePool.getFingerprint(foURI, "table-column");
private static void blockToSaxon6Node(Block b, Builder builder, NamePool pool, Config config) throws Exception { if (b.isStyled()) { AttributeCollection emptyAtts = new AttributeCollection(pool); int elemId = pool.allocate(config.prefix, config.uri, ((StyledBlock) b).getStyle()); builder.startElement(elemId, emptyAtts, new int[0], 0); builder.characters(b.getText().toCharArray(), 0, b.getText() .length()); builder.endElement(elemId); } else { builder.characters(b.getText().toCharArray(), 0, b.getText() .length()); } }
throws TransformerException { int thisFingerprint = namePool.getFingerprint(nameCode); int colFingerprint = namePool.getFingerprint("", "col"); int XHTMLcolFingerprint = namePool.getFingerprint(xhtmlURI, "col"); int foColFingerprint = namePool.getFingerprint(foURI, "table-column"); int widthFingerprint = namePool.getFingerprint("", "width"); } else if (thisFingerprint == foColFingerprint) { AttributeCollection attr = new AttributeCollection(namePool, attributes); int widthFingerprint = namePool.getFingerprint("", "column-width");
throws TransformerException { int thisFingerprint = namePool.getFingerprint(nameCode); boolean isLink = (thisFingerprint == htmlAFingerprint || thisFingerprint == xhtmlAFingerprint);
int thisFingerprint = namePool.getFingerprint(nameCode); boolean isLink = (thisFingerprint == htmlAFingerprint || thisFingerprint == xhtmlAFingerprint);
public static NodeEnumeration tokenize(Context context, String str, String pattern) throws XPathException { try { Builder builder = context.getController().makeBuilder(); NamePool pool = context.getController().getNamePool(); builder.setNamePool(pool); builder.startDocument(); int name = pool.allocate("", "", "token"); AttributeCollection emptyAtts = new AttributeCollection(pool); String[] tokens = str.split(pattern); for(String token: tokens) { builder.startElement(name, emptyAtts, new int[0], 0); builder.characters(token.toCharArray(), 0, token.length()); builder.endElement(name); } builder.endDocument(); DocumentInfo doc = builder.getCurrentDocument(); return doc.getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()); } catch (Exception err) { ExtensionFunctionUtils.setExtensionFunctionError(err); throw new XPathException(err); } }