bool ElemUse::processUseAttributeSets( StylesheetConstructionContext& constructionContext, const XalanDOMChar* attrName, const AttributeListType& atts, int which) { bool isUAS = false; if(StylesheetConstructionContext::ELEMNAME_LITERAL_RESULT == getXSLToken()) { isUAS = constructionContext.isXSLUseAttributeSetsAttribute( attrName, getStylesheet(), getLocator()); } else { isUAS = equals(attrName, Constants::ATTRNAME_USEATTRIBUTESETS); } if(isUAS == true) { m_attributeSetsNames = constructionContext.tokenizeQNames( m_attributeSetsNamesCount, atts.getValue(which), getStylesheet().getNamespaces(), getLocator()); assert(m_attributeSetsNamesCount == 0 || m_attributeSetsNames != 0); } return isUAS; }
void ElemVariable::init( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts) { const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if (equals(aname, Constants::ATTRNAME_SELECT)) { m_selectPattern = constructionContext.createXPath(getLocator(), atts.getValue(i), *this); } else if (equals(aname, Constants::ATTRNAME_NAME)) { m_qname = constructionContext.createXalanQName( atts.getValue(i), stylesheetTree.getNamespaces(), getLocator()); if (m_qname->isValid() == false) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::AttributeValueNotValidQName_2Param, Constants::ATTRNAME_NAME.c_str(), atts.getValue(i)), 0, this); } } else if(!(isAttrOK(aname, atts, i, constructionContext) || processSpaceAttr(aname, atts, i, constructionContext))) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_VARIABLE_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } if(m_qname == 0) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateMustHaveAttribute_2Param, Constants::ELEMNAME_VARIABLE_WITH_PREFIX_STRING, Constants::ATTRNAME_NAME), 0, this); } }
const ElemTemplateElement* ElemUse::getNextAttributeSet( StylesheetExecutionContext& executionContext) const { const StylesheetRoot& theStylesheetRoot = getStylesheet().getStylesheetRoot(); StylesheetExecutionContext::UseAttributeSetIndexes& useAttributeSetIndexes = executionContext.getUseAttributeSetIndexes(); const ElemTemplateElement* attributeSet = 0; while (0 == attributeSet && useAttributeSetIndexes.attributeSetNameIndex < m_attributeSetsNamesCount) { attributeSet = theStylesheetRoot.getAttributeSet( executionContext, *m_attributeSetsNames[useAttributeSetIndexes.attributeSetNameIndex], useAttributeSetIndexes.matchingAttributeSetIndex++, getLocator()); if (0 == attributeSet) { useAttributeSetIndexes.attributeSetNameIndex++; useAttributeSetIndexes.matchingAttributeSetIndex = 0; } } return attributeSet; }
XALAN_CPP_NAMESPACE_BEGIN ElemExtensionCall::ElemExtensionCall( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const XalanDOMChar* name, const AttributeListType& atts, int lineNumber, int columnNumber, ExtensionNSHandler& ns) : ElemLiteralResult(constructionContext, stylesheetTree, name, atts, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_EXTENSION_CALL), m_qname( constructionContext.createXalanQName( name, getStylesheet().getNamespaces(), getLocator())), m_nsh(ns) { assert(m_qname != 0); }
void ElemMessage::execute(StylesheetExecutionContext& executionContext) const { ElemTemplateElement::execute(executionContext); StylesheetExecutionContext::GetAndReleaseCachedString theResult(executionContext); const XalanDOMString& theString = childrenToString( executionContext, theResult.get()); const LocatorType* const theLocator = getLocator(); executionContext.message( theString, executionContext.getCurrentNode(), theLocator); if (m_terminate == true) { if (theLocator != 0) { throw ElemMessageTerminateException(*theLocator, theString); } else { throw ElemMessageTerminateException(theString); } } }
XALAN_CPP_NAMESPACE_BEGIN ElemPI::ElemPI( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, XalanFileLoc lineNumber, XalanFileLoc columnNumber) : ElemTemplateElement( constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_PI), m_nameAVT(0) { const XalanSize_t nAttrs = atts.getLength(); for(XalanSize_t i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if (equals(aname, Constants::ATTRNAME_NAME)) { m_nameAVT = constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this); } else if (isAttrOK( aname, atts, i, constructionContext) == false && processSpaceAttr( Constants::ELEMNAME_PI_WITH_PREFIX_STRING.c_str(), aname, atts, i, constructionContext) == false) { error( constructionContext, XalanMessages::ElementHasIllegalAttribute_2Param, Constants::ELEMNAME_PI_WITH_PREFIX_STRING.c_str(), aname); } } if (0 == m_nameAVT) { error( constructionContext, XalanMessages::ElementMustHaveAttribute_2Param, Constants::ELEMNAME_PI_WITH_PREFIX_STRING, Constants::ATTRNAME_NAME); } }
XALAN_CPP_NAMESPACE_BEGIN ElemForEach::ElemForEach( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemTemplateElement(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_FOR_EACH), m_selectPattern(0), m_sortElems(), m_sortElemsCount(0) { const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if(equals(aname, Constants::ATTRNAME_SELECT)) { m_selectPattern = constructionContext.createXPath(getLocator(), atts.getValue(i), *this); } else if(!(isAttrOK(aname, atts, i, constructionContext) || processSpaceAttr(aname, atts, i, constructionContext))) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_FOREACH_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } if(0 == m_selectPattern) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateMustHaveAttribute_2Param, Constants::ELEMNAME_FOREACH_WITH_PREFIX_STRING, Constants::ATTRNAME_SELECT), 0, this); } }
void ElemUse::doExecute( StylesheetExecutionContext& executionContext, bool applyAttributeSets) const { assert(m_attributeSetsNamesCount == 0 || m_attributeSetsNames != 0); ElemTemplateElement::execute(executionContext); if(applyAttributeSets == true && m_attributeSetsNamesCount > 0) { assert(canGenerateAttributes() == true); const StylesheetRoot& theStylesheetRoot = getStylesheet().getStylesheetRoot(); const LocatorType* const theLocator = getLocator(); for(size_type i = 0; i < m_attributeSetsNamesCount; ++i) { theStylesheetRoot.executeAttributeSet(executionContext, *m_attributeSetsNames[i], theLocator); } } }
XALAN_CPP_NAMESPACE_BEGIN ElemAttributeSet::ElemAttributeSet( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, XalanFileLoc lineNumber, XalanFileLoc columnNumber) : ElemUse(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_ATTRIBUTE_SET), m_qname(0) { const XalanSize_t nAttrs = atts.getLength(); for (XalanSize_t i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if (equals(aname, Constants::ATTRNAME_NAME)) { m_qname = constructionContext.createXalanQName( atts.getValue(i), stylesheetTree.getNamespaces(), getLocator()); if (m_qname->isValid() == false) { error( constructionContext, XalanMessages::AttributeValueNotValidQName_2Param, aname, atts.getValue(i)); } } else if (processUseAttributeSets( constructionContext, aname, atts, i) == false && isAttrOK( aname, atts, i, constructionContext) == false) { error( constructionContext, XalanMessages::ElementHasIllegalAttribute_2Param, Constants::ELEMNAME_ATTRIBUTESET_WITH_PREFIX_STRING.c_str(), aname); } } if (m_qname == 0) { error( constructionContext, XalanMessages::ElementMustHaveAttribute_2Param, Constants::ELEMNAME_ATTRIBUTESET_WITH_PREFIX_STRING, Constants::ATTRNAME_NAME); } assert(m_qname->isValid() == true); }
ElemTemplate::ElemTemplate( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemTemplateElement(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_TEMPLATE), m_matchPattern(0), m_name(&s_empty), m_mode(&s_empty), m_priority(XPath::getMatchScoreValue(XPath::eMatchScoreNone)) { const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if (equals(aname, Constants::ATTRNAME_MATCH)) { m_matchPattern = constructionContext.createMatchPattern(getLocator(), atts.getValue(i), *this); } else if (equals(aname, Constants::ATTRNAME_NAME)) { m_name = constructionContext.createXalanQName( atts.getValue(i), getStylesheet().getNamespaces(), getLocator()); if (m_name->isValid() == false) { error( constructionContext, XalanMessages::AttributeValueNotValidQName_2Param, aname, atts.getValue(i)); } } else if (equals(aname, Constants::ATTRNAME_PRIORITY)) { assert(atts.getValue(i) != 0); m_priority = DoubleSupport::toDouble(atts.getValue(i), constructionContext.getMemoryManager()); } else if (equals(aname, Constants::ATTRNAME_MODE)) { m_mode = constructionContext.createXalanQName( atts.getValue(i), getStylesheet().getNamespaces(), getLocator()); if (m_mode->isValid() == false) { error( constructionContext, XalanMessages::AttributeValueNotValidQName_2Param, aname, atts.getValue(i)); } } else if(isAttrOK( aname, atts, i, constructionContext) == false && processSpaceAttr( Constants::ELEMNAME_TEMPLATE_WITH_PREFIX_STRING.c_str(), aname, atts, i, constructionContext) == false) { error( constructionContext, XalanMessages::ElementHasIllegalAttribute_2Param, Constants::ELEMNAME_TEMPLATE_WITH_PREFIX_STRING.c_str(), aname); } } if(0 == m_matchPattern && m_name->isEmpty() == true) { error( constructionContext, XalanMessages::ElementRequiresEitherNameOrMatchAttribute_1Param, Constants::ELEMNAME_TEMPLATE_WITH_PREFIX_STRING); } assert(m_name->isEmpty() == true || m_name->isValid() == true); assert(m_mode->isEmpty() == true || m_mode->isValid() == true); }
void ElemLiteralResult::init( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const XalanDOMChar* name, const AttributeListType& atts) { assert(name != 0); hasPrefix(indexOf(name, XalanUnicode::charColon) < length(name) ? true : false); const unsigned int nAttrs = atts.getLength(); // This over-allocates, but we probably won't waste that much space. m_avts = constructionContext.allocateAVTPointerVector(nAttrs); assert(m_avts != 0); const StylesheetConstructionContext::GetAndReleaseCachedString theGuard(constructionContext); XalanDOMString& theBuffer = theGuard.get(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); bool needToProcess = true; const XalanDOMString::size_type indexOfNSSep = indexOf(aname, XalanUnicode::charColon); const XalanDOMString::size_type len = length(aname); if(indexOfNSSep < len) { substring(aname, theBuffer, 0, indexOfNSSep); if(!equals(theBuffer, DOMServices::s_XMLNamespace)) { const XalanDOMString* const ns = getNamespaceForPrefixInternal(theBuffer); if(ns == 0) { constructionContext.error( XalanMessageLoader::getMessage(XalanMessages::UndeclaredNamespacePrefix_1Param, theBuffer), 0, this); } else if(equals(*ns, stylesheetTree.getXSLTNamespaceURI())) { theBuffer.assign(aname + indexOfNSSep + 1, len - (indexOfNSSep + 1)); if(processPrefixControl(constructionContext, stylesheetTree, theBuffer, atts.getValue(i)) == true) { needToProcess = false; } else if (equals(theBuffer, Constants::ATTRNAME_VERSION) == true) { const XalanDOMChar* const value = atts.getValue(i); stylesheetTree.setXSLTVerDeclared(DoubleSupport::toDouble(value)); } } } else { // don't process namespace decls needToProcess = false; } } if(needToProcess == true) { processSpaceAttr(aname, atts, i, constructionContext); // Add xmlns attribute(except xmlns:xsl), xml:space, etc... // Ignore anything with xsl:xxx if(! processUseAttributeSets(constructionContext, aname, atts, i) && isAttrOK(aname, atts, i, constructionContext)) { m_avts[m_avtsCount++] = constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this); } } } }
XALAN_CPP_NAMESPACE_BEGIN ElemElement::ElemElement( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemUse(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_ELEMENT), m_nameAVT(0), m_namespaceAVT(0) { // Namespace aliases are not used for xsl:element, so // turn them off... // m_namespacesHandler.setProcessNamespaceAliaises(false); const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if(equals(aname, Constants::ATTRNAME_NAME)) { m_nameAVT = constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this); } else if(equals(aname, Constants::ATTRNAME_NAMESPACE)) { m_namespaceAVT = constructionContext.createAVT(getLocator(), aname, atts.getValue(i), *this); } else if(!(processUseAttributeSets(constructionContext, aname, atts, i) || processSpaceAttr(aname, atts, i, constructionContext) || isAttrOK(aname, atts, i, constructionContext))) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_ELEMENT_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } if(0 == m_nameAVT) { constructionContext.error( XalanMessageLoader::getMessage(XalanMessages::TemplateMustHaveAttribute_2Param ,Constants::ELEMNAME_ELEMENT_WITH_PREFIX_STRING ,Constants::ATTRNAME_NAME), 0, this); } }
void ElemElement::execute(StylesheetExecutionContext& executionContext) const { StylesheetExecutionContext::GetAndReleaseCachedString elemNameGuard(executionContext); XalanDOMString& elemName = elemNameGuard.get(); m_nameAVT->evaluate(elemName, *this, executionContext); bool isIllegalElement = !XalanQName::isValidQName(elemName); if (isIllegalElement == true) { executionContext.warn( XalanMessageLoader::getMessage(XalanMessages::IllegalElementName_1Param, elemName), executionContext.getCurrentNode(), getLocator()); ElemUse::doExecute(executionContext, false); doExecuteChildren(executionContext, true); } else { StylesheetExecutionContext::GetAndReleaseCachedString elemNameSpaceGuard(executionContext); XalanDOMString& elemNameSpace = elemNameSpaceGuard.get(); if (m_namespaceAVT != 0) { m_namespaceAVT->evaluate(elemNameSpace, *this, executionContext); } XalanDOMString::size_type namespaceLen = length(elemNameSpace); bool foundResultNamespaceForPrefix = false; XalanDOMString::size_type len = length(elemName); const XalanDOMString::size_type indexOfNSSep = indexOf(elemName, XalanUnicode::charColon); const bool havePrefix = indexOfNSSep == len ? false : true; StylesheetExecutionContext::GetAndReleaseCachedString prefixGuard(executionContext); XalanDOMString& prefix = prefixGuard.get(); if (havePrefix == true) { substring(elemName, prefix, 0, indexOfNSSep); const XalanDOMString* const theNamespace = executionContext.getResultNamespaceForPrefix(prefix); if (theNamespace != 0) { foundResultNamespaceForPrefix = true; } else { const XalanDOMString* const theNamespace = getNamespacesHandler().getNamespace(prefix); if(theNamespace == 0 && namespaceLen == 0) { executionContext.warn( XalanMessageLoader::getMessage( XalanMessages::CannotResolvePrefix_1Param, prefix), executionContext.getCurrentNode(), getLocator()); if (m_namespaceAVT != 0) { elemName.erase(0, indexOfNSSep + 1); } else { isIllegalElement = true; executionContext.warn( XalanMessageLoader::getMessage( XalanMessages::IllegalElementName_1Param, elemName), executionContext.getCurrentNode(), getLocator()); } } else if (theNamespace != 0 && namespaceLen == 0 && equals(prefix, DOMServices::s_XMLNamespace) == false) { elemNameSpace = *theNamespace; } } } if (isIllegalElement == false) { executionContext.startElement(c_wstr(elemName)); if(0 == m_namespaceAVT && (havePrefix == false || foundResultNamespaceForPrefix == true)) { if (havePrefix == false) { fixupDefaultNamespace(executionContext); } } else { if(havePrefix == false) { if (namespaceLen > 0) { const XalanDOMString* const theDefaultNamespace = executionContext.getResultNamespaceForPrefix(s_emptyString); if (theDefaultNamespace == 0 || equals(*theDefaultNamespace, elemNameSpace) == false) { executionContext.addResultAttribute( DOMServices::s_XMLNamespace, elemNameSpace); } } else { // OK, the namespace we're generating is the default namespace, // so let's make sure that we really need it. If we don't, // we end up with another xmlns="" on the element we're // generating. Although this isn't really an error, it's // a bit unsightly, so let's suppress it... const XalanDOMString& theParentDefaultNamespace = getParentDefaultNamespace(); if (length(theParentDefaultNamespace) == 0) { if (executionContext.getResultNamespaceForPrefix(s_emptyString) != 0) { executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace); } } else { executionContext.addResultAttribute(DOMServices::s_XMLNamespace, elemNameSpace); } } } else { const XalanDOMString* const theNamespace = executionContext.getResultNamespaceForPrefix(prefix); if (theNamespace == 0 || equals(*theNamespace, elemNameSpace) == false) { insert(prefix, 0, DOMServices::s_XMLNamespaceWithSeparator); executionContext.addResultAttribute(prefix, elemNameSpace); } } } } if (isIllegalElement == true) { ElemUse::doExecute(executionContext, false); doExecuteChildren(executionContext, true); } else { ElemUse::doExecute(executionContext, true); doExecuteChildren(executionContext, false); executionContext.endElement(c_wstr(elemName)); } } }
XALAN_CPP_NAMESPACE_BEGIN ElemWithParam::ElemWithParam( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemTemplateElement(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_WITH_PARAM), m_selectPattern(0), m_qname(0) { const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if(equals(aname, Constants::ATTRNAME_SELECT)) { m_selectPattern = constructionContext.createXPath(getLocator(), atts.getValue(i), *this); } else if(equals(aname, Constants::ATTRNAME_NAME)) { m_qname = constructionContext.createXalanQName( atts.getValue(i), stylesheetTree.getNamespaces(), getLocator()); if (m_qname->isValid() == false) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::AttributeValueNotValidQName_2Param, Constants::ATTRNAME_NAME.c_str(), atts.getValue(i)), 0, this); } } else if(!isAttrOK(aname, atts, i, constructionContext)) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_WITHPARAM_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } if(m_qname == 0) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateMustHaveAttribute_2Param, Constants::ELEMNAME_WITHPARAM_WITH_PREFIX_STRING, Constants::ATTRNAME_NAME), 0, this); } }