public void prepareAttributes() throws XPathException { AttributeCollection atts = getAttributeList(); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.NAME)) { nameAttribute = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(nc); reportAbsence("name"); return; if (allowAVT() && nameAttribute.indexOf('{')>=0) { calledTemplateExpression = makeAttributeValueTemplate(nameAttribute); } else { try { calledTemplateName = makeQName(nameAttribute); } catch (NamespaceException err) { calledTemplateName = new StructuredQName("saxon", NamespaceConstant.SAXON, "error-template"); compileError(err.getMessage(), "XTSE0280"); } catch (XPathException err) { calledTemplateName = new StructuredQName("saxon", NamespaceConstant.SAXON, "error-template"); compileError(err.getMessage(), "XTSE0280");
public void validate() throws XPathException { AxisIterator kids = iterateAxis(Axis.CHILD); while (true) { NodeInfo child = (NodeInfo)kids.next(); if (child == null) { break; } if (child instanceof XSLWithParam) { // OK; } else if (child instanceof XSLFallback && mayContainFallback()) { // xsl:fallback is not allowed on xsl:call-template, but is allowed on saxon:call-template (cheat!) } else if (child.getNodeKind() == Type.TEXT) { // with xml:space=preserve, white space nodes may still be there if (!Whitespace.isWhite(child.getStringValueCS())) { compileError("No character data is allowed within xsl:call-template", "XTSE0010"); } } else { compileError("Child element " + Err.wrap(child.getDisplayName(), Err.ELEMENT) + " is not allowed within xsl:call-template", "XTSE0010"); } } if (calledTemplateExpression==null) { template = findTemplate(calledTemplateName); if (template==null) { return; } } calledTemplateExpression = typeCheck("name", calledTemplateExpression); }
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { if (template == null) { return null; // error already reported } CallTemplate call = new CallTemplate(template, calledTemplateName, useTailRecursion, isWithinDeclaredStreamableConstruct()); call.setLocation(allocateLocation()); call.setActualParameters( getWithParamInstructions(call, exec, decl, false), getWithParamInstructions(call, exec, decl, true)); return call; }
private NamedTemplate findTemplate(StructuredQName templateName) throws XPathException { PrincipalStylesheetModule pack = getPrincipalStylesheetModule(); NamedTemplate template = pack.getNamedTemplate(templateName); if (template == null) { if (templateName.hasURI(NamespaceConstant.XSLT) && templateName.getLocalPart().equals("original")) { // Handle xsl:original return (NamedTemplate) getXslOriginal(StandardNames.XSL_TEMPLATE); } compileError("Cannot find a template named " + calledTemplateName, "XTSE0650"); } return template; }
public Expression compile(Executable exec) throws XPathException { Template target = null; NamespaceResolver nsContext = null; if (calledTemplateExpression==null) { if (template==null) { return null; // error already reported } target = template.getCompiledTemplate(); } else { //getPrincipalStyleSheet().setRequireRuntimeTemplateMap(true); nsContext = makeNamespaceContext(); } CallTemplate call = new CallTemplate ( target, useTailRecursion, calledTemplateExpression, nsContext ); call.setActualParameters(getWithParamInstructions(exec, false, call), getWithParamInstructions(exec, true, call)); return call; }
public void prepareAttributes() throws XPathException { AttributeCollection atts = getAttributeList(); String nameAttribute = null; for (int a = 0; a < atts.getLength(); a++) { String f = atts.getQName(a); if (f.equals("name")) { nameAttribute = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(atts.getNodeName(a)); } } if (nameAttribute == null) { calledTemplateName = ERROR_TEMPLATE_NAME; reportAbsence("name"); return; } try { calledTemplateName = makeQName(nameAttribute); } catch (XPathException err) { calledTemplateName = ERROR_TEMPLATE_NAME; compileErrorInAttribute(err.getMessage(), err.getErrorCodeLocalPart(), "name"); } }
for (NamedTemplate.LocalParamInfo param : declaredParams) { if (param.isRequired && !param.isTunnel) { AxisIterator actualParams = iterateAxis(AxisInfo.CHILD); boolean ok = false; NodeInfo withParam; compileError("No value supplied for required parameter " + Err.wrap(param.name.getDisplayName(), Err.VARIABLE), "XTSE0690"); AxisIterator actualParams = iterateAxis(AxisInfo.CHILD); NodeInfo w; while ((w = actualParams.next()) != null) { if (!ok && !xPath10ModeIsEnabled()) { compileError("Parameter " + withParam.getVariableQName().getDisplayName() + " is not declared in the called template", "XTSE0680");
AxisIterator actualParams = iterateAxis(Axis.CHILD); boolean ok = false; while(true) { compileError("No value supplied for required parameter " + Err.wrap(((XSLParam)param).getVariableDisplayName(), Err.VARIABLE), "XTSE0690"); AxisIterator actualParams = iterateAxis(Axis.CHILD); while(true) { NodeInfo w = (NodeInfo)actualParams.next(); if (!backwardsCompatibleModeIsEnabled()) { compileError("Parameter " + withParam.getVariableDisplayName() + " is not declared in the called template", "XTSE0680");
return new XSLAttributeSet(); case StandardNames.XSL_CALL_TEMPLATE: return new XSLCallTemplate(); case StandardNames.XSL_CHARACTER_MAP: return new XSLCharacterMap();
private XSLTemplate findTemplate(StructuredQName templateName) throws XPathException { XSLStylesheet stylesheet = getPrincipalStylesheet(); List toplevel = stylesheet.getTopLevel(); // search for a matching template name, starting at the end in case of duplicates. // this also ensures we get the one with highest import precedence. for (int i=toplevel.size()-1; i>=0; i--) { if (toplevel.get(i) instanceof XSLTemplate) { XSLTemplate t = (XSLTemplate)toplevel.get(i); if (templateName.equals(t.getTemplateName())) { return t; } } } compileError("No template exists named " + calledTemplateName, "XTSE0650"); return null; }
public void prepareAttributes() throws XPathException { AttributeCollection atts = getAttributeList(); String nameAttribute = null; for (int a = 0; a < atts.getLength(); a++) { String f = atts.getQName(a); if (f.equals("name")) { nameAttribute = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(atts.getNodeName(a)); } } if (nameAttribute == null) { calledTemplateName = ERROR_TEMPLATE_NAME; reportAbsence("name"); return; } try { calledTemplateName = makeQName(nameAttribute); } catch (XPathException err) { calledTemplateName = ERROR_TEMPLATE_NAME; compileErrorInAttribute(err.getMessage(), err.getErrorCodeLocalPart(), "name"); } }
for (NamedTemplate.LocalParamInfo param : declaredParams) { if (param.isRequired && !param.isTunnel) { AxisIterator actualParams = iterateAxis(AxisInfo.CHILD); boolean ok = false; NodeInfo withParam; compileError("No value supplied for required parameter " + Err.wrap(param.name.getDisplayName(), Err.VARIABLE), "XTSE0690"); AxisIterator actualParams = iterateAxis(AxisInfo.CHILD); NodeInfo w; while ((w = actualParams.next()) != null) { if (!ok && !xPath10ModeIsEnabled()) { compileError("Parameter " + withParam.getVariableQName().getDisplayName() + " is not declared in the called template", "XTSE0680");
AxisIterator actualParams = iterateAxis(Axis.CHILD); boolean ok = false; while(true) { compileError("No value supplied for required parameter " + Err.wrap(((XSLParam)param).getVariableDisplayName(), Err.VARIABLE), "XTSE0690"); AxisIterator actualParams = iterateAxis(Axis.CHILD); while(true) { NodeInfo w = (NodeInfo)actualParams.next(); if (!backwardsCompatibleModeIsEnabled()) { compileError("Parameter " + withParam.getVariableDisplayName() + " is not declared in the called template", "XTSE0680");
private NamedTemplate findTemplate(StructuredQName templateName) throws XPathException { PrincipalStylesheetModule pack = getPrincipalStylesheetModule(); NamedTemplate template = pack.getNamedTemplate(templateName); if (template == null) { if (templateName.hasURI(NamespaceConstant.XSLT) && templateName.getLocalPart().equals("original")) { // Handle xsl:original return (NamedTemplate) getXslOriginal(StandardNames.XSL_TEMPLATE); } compileError("Cannot find a template named " + calledTemplateName, "XTSE0650"); } return template; }
return new XSLAttributeSet(); case StandardNames.XSL_CALL_TEMPLATE: return new XSLCallTemplate(); case StandardNames.XSL_CHARACTER_MAP: return new XSLCharacterMap();
private XSLTemplate findTemplate(StructuredQName templateName) throws XPathException { XSLStylesheet stylesheet = getPrincipalStylesheet(); List toplevel = stylesheet.getTopLevel(); // search for a matching template name, starting at the end in case of duplicates. // this also ensures we get the one with highest import precedence. for (int i=toplevel.size()-1; i>=0; i--) { if (toplevel.get(i) instanceof XSLTemplate) { XSLTemplate t = (XSLTemplate)toplevel.get(i); if (templateName.equals(t.getTemplateName())) { return t; } } } compileError("No template exists named " + calledTemplateName, "XTSE0650"); return null; }
public Expression compile(Executable exec) throws XPathException { Template target = null; NamespaceResolver nsContext = null; if (calledTemplateExpression==null) { if (template==null) { return null; // error already reported } target = template.getCompiledTemplate(); } else { //getPrincipalStyleSheet().setRequireRuntimeTemplateMap(true); nsContext = makeNamespaceContext(); } CallTemplate call = new CallTemplate ( target, useTailRecursion, calledTemplateExpression, nsContext ); call.setActualParameters(getWithParamInstructions(exec, false, call), getWithParamInstructions(exec, true, call)); return call; }
public void prepareAttributes() throws XPathException { AttributeCollection atts = getAttributeList(); String f = getNamePool().getClarkName(nc); if (f.equals(StandardNames.NAME)) { nameAttribute = Whitespace.trim(atts.getValue(a)); } else { checkUnknownAttribute(nc); reportAbsence("name"); return; if (allowAVT() && nameAttribute.indexOf('{')>=0) { calledTemplateExpression = makeAttributeValueTemplate(nameAttribute); } else { try { calledTemplateName = makeQName(nameAttribute); } catch (NamespaceException err) { calledTemplateName = new StructuredQName("saxon", NamespaceConstant.SAXON, "error-template"); compileError(err.getMessage(), "XTSE0280"); } catch (XPathException err) { calledTemplateName = new StructuredQName("saxon", NamespaceConstant.SAXON, "error-template"); compileError(err.getMessage(), err.getErrorCodeLocalPart());
public void validate(ComponentDeclaration decl) throws XPathException { AxisIterator kids = iterateAxis(AxisInfo.CHILD); while (true) { NodeInfo child = kids.next(); if (child == null) { break; } if (child instanceof XSLWithParam) { // OK; } else if (child instanceof XSLFallback && mayContainFallback()) { // xsl:fallback is not allowed on xsl:call-template, but is allowed on saxon:call-template (cheat!) } else if (child.getNodeKind() == Type.TEXT) { // with xml:space=preserve, white space nodes may still be there if (!Whitespace.isWhite(child.getStringValueCS())) { compileError("No character data is allowed within xsl:call-template", "XTSE0010"); } } else { compileError("Child element " + Err.wrap(child.getDisplayName(), Err.ELEMENT) + " is not allowed as a child of xsl:call-template", "XTSE0010"); } } if (!calledTemplateName.equals(ERROR_TEMPLATE_NAME)) { template = findTemplate(calledTemplateName); } }
public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException { if (template == null) { return null; // error already reported } CallTemplate call = new CallTemplate(template, calledTemplateName, useTailRecursion, isWithinDeclaredStreamableConstruct()); call.setLocation(allocateLocation()); call.setActualParameters( getWithParamInstructions(call, exec, decl, false), getWithParamInstructions(call, exec, decl, true)); return call; }