/** * Get a character map, identified by the fingerprint of its name. * Search backwards through the stylesheet. * @param name The character map name being sought * @return the identified character map, or null if not found */ public XSLCharacterMap getCharacterMap(StructuredQName name) { for (int i = topLevel.size() - 1; i >= 0; i--) { if (topLevel.get(i) instanceof XSLCharacterMap) { XSLCharacterMap t = (XSLCharacterMap) topLevel.get(i); if (t.getCharacterMapName().equals(name)) { return t; } } } return null; }
checkTopLevel(null); AxisIterator kids = iterateAxis(Axis.CHILD); while (true) { Item child = kids.next(); compileError("Only xsl:output-character is allowed within xsl:character-map", "XTSE0010"); XSLStylesheet principal = getPrincipalStylesheet(); XSLCharacterMap other = principal.getCharacterMap(getObjectName()); if (other != this) { if (getPrecedence() == other.getPrecedence()) { compileError("There are two character-maps with the same name and import precedence", "XTSE1580"); } else if (getPrecedence() < other.getPrecedence()) { redundant = true; String displayname = st.nextToken(); try { String[] parts = getConfiguration().getNameChecker().getQNameParts(displayname); String uri = getURIForPrefix(parts[0], false); if (uri == null) { compileError("Undeclared namespace prefix " + Err.wrap(parts[0]) + " in character map name", "XTSE0280"); XSLCharacterMap ref = principal.getCharacterMap(qn); if (ref == null) { compileError("No character-map named '" + displayname + "' has been defined", "XTSE1590"); } else { characterMapElements.add(ref);
use = null; AttributeCollection atts = getAttributeList(); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.NAME)) { name = Whitespace.trim(atts.getValue(a)); use = atts.getValue(a); } else { checkUnknownAttribute(nc); reportAbsence("name"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(makeQName(name)); } catch (NamespaceException err) { compileError(err.getMessage(), "XTSE0280"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(new StructuredQName("", "", name)); } catch (XPathException err) { compileError(err.getMessage(), "XTSE0020"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(new StructuredQName("", "", name));
/** * Check for circularity: specifically, check that this attribute set does not contain * a direct or indirect reference to the one supplied as a parameter * * @param origin the start point of the search * @throws net.sf.saxon.trans.XPathException * if an error is detected */ private void checkCircularity(XSLCharacterMap origin) throws XPathException { if (this == origin) { compileError("The definition of the character map is circular", "XTSE1600"); characterMapElements = null; // for error recovery } else { if (!validated) { // if this attribute set isn't validated yet, we don't check it. // The circularity will be detected when the last attribute set in the cycle // gets validated return; } if (characterMapElements != null) { for (Object characterMapElement : characterMapElements) { ((XSLCharacterMap) characterMapElement).checkCircularity(origin); } } } }
/** * Get the fingerprint of the name of this character map * @return the fingerprint value */ public StructuredQName getCharacterMapName() { StructuredQName name = getObjectName(); if (name == null) { try { return makeQName(getAttributeValue("name")); } catch (Exception err) { // the error will be reported later return new StructuredQName("", "", "unnamedCharacterMap_" + hashCode()); } } return name; }
/** * Get the fingerprint of the name of this character map * * @return the fingerprint value */ public StructuredQName getCharacterMapName() { StructuredQName name = getObjectName(); if (name == null) { try { return makeQName(getAttributeValue("", "name")); } catch (Exception err) { // the error will be reported later return new StructuredQName("", "", "unnamedCharacterMap_" + hashCode()); } } return name; }
checkTopLevel("XTSE0010", false); iterateAxis(AxisInfo.CHILD).forEachOrFail(child -> { if (!(child instanceof XSLOutputCharacter)) { compileError("Only xsl:output-character is allowed within xsl:character-map", "XTSE0010"); PrincipalStylesheetModule psm = getPrincipalStylesheetModule(); ComponentDeclaration other = psm.getCharacterMap(getObjectName()); if (other.getSourceElement() != this) { if (decl.getPrecedence() == other.getPrecedence()) { compileError("There are two character-maps with the same name and import precedence", "XTSE1580"); } else if (decl.getPrecedence() < other.getPrecedence()) { redundant = true; try { String[] parts = NameChecker.getQNameParts(displayname); String uri = getURIForPrefix(parts[0], false); if (uri == null) { compileError("Undeclared namespace prefix " + Err.wrap(parts[0]) + " in character map name", "XTSE0280"); ComponentDeclaration charMapDecl = psm.getCharacterMap(qn); if (charMapDecl == null) { compileError("No character-map named '" + displayname + "' has been defined", "XTSE1590"); } else { XSLCharacterMap ref = (XSLCharacterMap) charMapDecl.getSourceElement(); compileError("Invalid character-map name. " + err.getMessage(), "XTSE1590");
use = null; AttributeCollection atts = getAttributeList(); use = atts.getValue(a); } else { checkUnknownAttribute(atts.getNodeName(a)); reportAbsence("name"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(makeQName(name)); } catch (XPathException err) { compileError(err.getMessage(), "XTSE0020"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(new StructuredQName("", "", name));
if (topLevel.get(i) instanceof XSLCharacterMap) { XSLCharacterMap t = (XSLCharacterMap) topLevel.get(i); if (!t.isRedundant()) { StructuredQName qn = t.getCharacterMapName(); IntHashMap map = new IntHashMap(20); t.assemble(map); if (exec.getCharacterMapIndex() == null) { exec.setCharacterMapIndex(new HashMap(20));
/** * Assemble all the mappings defined by this character map, adding them to a * HashMap that maps integer codepoints to strings * @param map a hash map to be populated with the character mappings */ public void assemble(IntHashMap map) { if (characterMapElements != null) { for (int i = 0; i < characterMapElements.size(); i++) { XSLCharacterMap charmap = (XSLCharacterMap) characterMapElements.get(i); charmap.assemble(map); } } AxisIterator kids = iterateAxis(Axis.CHILD); while (true) { Item child = kids.next(); if (child == null) { return; } XSLOutputCharacter oc = (XSLOutputCharacter)child; map.put(oc.getCodePoint(), oc.getReplacementString()); } }
if (inst instanceof XSLCharacterMap) { XSLCharacterMap xcm = (XSLCharacterMap) inst; StructuredQName qn = xcm.getCharacterMapName(); IntHashMap<String> map = new IntHashMap<>(); xcm.assemble(map); characterMapIndex.putCharacterMap(xcm.getCharacterMapName(), new CharacterMap(qn, map));
return new XSLCallTemplate(); case StandardNames.XSL_CHARACTER_MAP: return new XSLCharacterMap(); case StandardNames.XSL_CHOOSE: return new XSLChoose();
/** * Get the fingerprint of the name of this character map * @return the fingerprint value */ public StructuredQName getCharacterMapName() { return getObjectName(); }
checkTopLevel("XTSE0010", false); iterateAxis(AxisInfo.CHILD).forEachOrFail(child -> { if (!(child instanceof XSLOutputCharacter)) { compileError("Only xsl:output-character is allowed within xsl:character-map", "XTSE0010"); PrincipalStylesheetModule psm = getPrincipalStylesheetModule(); ComponentDeclaration other = psm.getCharacterMap(getObjectName()); if (other.getSourceElement() != this) { if (decl.getPrecedence() == other.getPrecedence()) { compileError("There are two character-maps with the same name and import precedence", "XTSE1580"); } else if (decl.getPrecedence() < other.getPrecedence()) { redundant = true; try { String[] parts = NameChecker.getQNameParts(displayname); String uri = getURIForPrefix(parts[0], false); if (uri == null) { compileError("Undeclared namespace prefix " + Err.wrap(parts[0]) + " in character map name", "XTSE0280"); ComponentDeclaration charMapDecl = psm.getCharacterMap(qn); if (charMapDecl == null) { compileError("No character-map named '" + displayname + "' has been defined", "XTSE1590"); } else { XSLCharacterMap ref = (XSLCharacterMap) charMapDecl.getSourceElement(); compileError("Invalid character-map name. " + err.getMessage(), "XTSE1590");
use = null; AttributeCollection atts = getAttributeList(); use = atts.getValue(a); } else { checkUnknownAttribute(atts.getNodeName(a)); reportAbsence("name"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(makeQName(name)); } catch (XPathException err) { compileError(err.getMessage(), "XTSE0020"); name = "unnamedCharacterMap_" + hashCode(); setObjectName(new StructuredQName("", "", name));
if (topLevel.get(i) instanceof XSLCharacterMap) { XSLCharacterMap t = (XSLCharacterMap) topLevel.get(i); if (!t.isRedundant()) { StructuredQName qn = t.getCharacterMapName(); IntHashMap map = new IntHashMap(20); t.assemble(map); if (exec.getCharacterMapIndex() == null) { exec.setCharacterMapIndex(new HashMap(20));
/** * Assemble all the mappings defined by this character map, adding them to a * HashMap that maps integer codepoints to strings * @param map a hash map to be populated with the character mappings */ public void assemble(IntHashMap map) { if (characterMapElements != null) { for (int i = 0; i < characterMapElements.size(); i++) { XSLCharacterMap charmap = (XSLCharacterMap) characterMapElements.get(i); charmap.assemble(map); } } AxisIterator kids = iterateAxis(Axis.CHILD); while (true) { Item child = kids.next(); if (child == null) { return; } XSLOutputCharacter oc = (XSLOutputCharacter)child; map.put(oc.getCodePoint(), oc.getReplacementString()); } }
/** * Check for circularity: specifically, check that this attribute set does not contain * a direct or indirect reference to the one supplied as a parameter * * @param origin the start point of the search * @throws net.sf.saxon.trans.XPathException * if an error is detected */ private void checkCircularity(XSLCharacterMap origin) throws XPathException { if (this == origin) { compileError("The definition of the character map is circular", "XTSE1600"); characterMapElements = null; // for error recovery } else { if (!validated) { // if this attribute set isn't validated yet, we don't check it. // The circularity will be detected when the last attribute set in the cycle // gets validated return; } if (characterMapElements != null) { for (Object characterMapElement : characterMapElements) { ((XSLCharacterMap) characterMapElement).checkCircularity(origin); } } } }
/** * Get the fingerprint of the name of this character map * * @return the fingerprint value */ public StructuredQName getCharacterMapName() { StructuredQName name = getObjectName(); if (name == null) { try { return makeQName(getAttributeValue("", "name")); } catch (Exception err) { // the error will be reported later return new StructuredQName("", "", "unnamedCharacterMap_" + hashCode()); } } return name; }
if (inst instanceof XSLCharacterMap) { XSLCharacterMap xcm = (XSLCharacterMap) inst; StructuredQName qn = xcm.getCharacterMapName(); IntHashMap<String> map = new IntHashMap<>(); xcm.assemble(map); characterMapIndex.putCharacterMap(xcm.getCharacterMapName(), new CharacterMap(qn, map));