void ElemVariable::addToStylesheet( StylesheetConstructionContext& constructionContext, Stylesheet& theStylesheet) { // Processing a top-level element only... if (&theStylesheet != &getStylesheet()) { constructionContext.error( XalanMessageLoader::getMessage(XalanMessages::ElemVariableInstanceAddedToWrongStylesheet), 0, this); } else if (getParentNodeElem() != 0) { constructionContext.error( XalanMessageLoader::getMessage(XalanMessages::ElemVariableInstanceIsAlreadyParented), 0, this); } else { theStylesheet.setTopLevelVariable(this); m_isTopLevel = true; } }
bool addOrUpdateByPrefix( StylesheetConstructionContext& theConstructionContext, VectorType& theVector, const XalanDOMString& thePrefix, const XalanDOMString& theURI) { typedef typename VectorType::value_type value_type; value_type* const theEntry = findByPrefixNonConst(theVector, thePrefix); if (theEntry == 0) { theVector.push_back( value_type( theConstructionContext.getPooledString(thePrefix), theConstructionContext.getPooledString(theURI))); return true; } else { if (theEntry->getURI() == theURI) { return false; } else { theEntry->setURI(theConstructionContext.getPooledString(theURI)); return true; } } }
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; }
NamespacesHandler::NamespacesHandler( StylesheetConstructionContext& theConstructionContext, const NamespacesHandler& /* stylesheetNamespacesHandler */, const NamespacesStackType& theCurrentNamespaces, const XalanDOMString& theXSLTNamespaceURI) : m_excludedResultPrefixes(theConstructionContext.getMemoryManager()), m_namespaceDeclarations(theConstructionContext.getMemoryManager()), m_extensionNamespaceURIs(theConstructionContext.getMemoryManager()), m_namespaceAliases(theConstructionContext.getMemoryManager()) { // Go through the namespaces stack in reverse order... const NamespacesStackType::const_reverse_iterator theEnd = theCurrentNamespaces.rend(); NamespacesStackType::const_reverse_iterator i = theCurrentNamespaces.rbegin(); for(; i != theEnd; ++i) { // Process each namespace in the current vector... const NamespaceVectorType::const_iterator theVectorEnd = (*i).end(); NamespaceVectorType::const_iterator j = (*i).begin(); for(; j != theVectorEnd; ++j) { const NameSpace& theNamespace = *j; const XalanDOMString& theURI = theNamespace.getURI(); const XalanDOMString& thePrefix = theNamespace.getPrefix(); if(shouldExcludeResultNamespaceNode( theXSLTNamespaceURI, theURI) == false) { addByPrefix( theConstructionContext, m_namespaceDeclarations, thePrefix, theURI); } else { addByPrefix( theConstructionContext, m_excludedResultPrefixes, thePrefix, theURI); assert(findByPrefix(m_excludedResultPrefixes, thePrefix) != 0 && findByPrefix(m_excludedResultPrefixes, thePrefix)->getURI() == theURI); } } } }
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); } }
void NamespacesHandler::setNamespaceAlias( StylesheetConstructionContext& theConstructionContext, const XalanDOMString& theStylesheetNamespace, const XalanDOMString& theResultNamespace) { m_namespaceAliases[&theConstructionContext.getPooledString(theStylesheetNamespace)] = &theConstructionContext.getPooledString(theResultNamespace); }
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); } }
XALAN_CPP_NAMESPACE_BEGIN ElemMessage::ElemMessage( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemTemplateElement(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_MESSAGE), m_terminate(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_TERMINATE) == true) { const XalanDOMChar* const avalue = atts.getValue(i); if (equals(avalue, Constants::ATTRVAL_YES) == true) { m_terminate = true; } else if (equals(avalue, Constants::ATTRVAL_NO) == false) { constructionContext.error( XalanMessageLoader::getMessage(XalanMessages::AttributeHasIllegalValue_1Param,Constants::ATTRNAME_TERMINATE), 0, this); } } else if(isAttrOK(aname, atts, i, constructionContext) == false || processSpaceAttr(aname, atts, i, constructionContext)) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_MESSAGE_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } }
void NamespacesHandler::addExtensionNamespaceURI( StylesheetConstructionContext& theConstructionContext, const XalanDOMString& theURI) { m_extensionNamespaceURIs.push_back(&theConstructionContext.getPooledString(theURI)); }
XALAN_CPP_NAMESPACE_BEGIN ElemComment::ElemComment( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemTemplateElement(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_COMMENT) { const unsigned int nAttrs = atts.getLength(); for(unsigned int i = 0; i < nAttrs; i++) { const XalanDOMChar* const aname = atts.getName(i); if(isAttrOK(aname, atts, i, constructionContext) == false || processSpaceAttr(aname, atts, i, constructionContext)) { constructionContext.error( XalanMessageLoader::getMessage( XalanMessages::TemplateHasIllegalAttribute_2Param, Constants::ELEMNAME_COMMENT_WITH_PREFIX_STRING.c_str(), aname), 0, this); } } }
XALAN_CPP_NAMESPACE_BEGIN ElemTextLiteral::ElemTextLiteral( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, XalanFileLoc lineNumber, XalanFileLoc columnNumber, const XMLCh* ch, XalanDOMString::size_type start, XalanDOMString::size_type length, bool fPreserveSpace, bool fDisableOutputEscaping) : ElemTemplateElement( constructionContext, stylesheetTree, StylesheetConstructionContext::ELEMNAME_TEXT_LITERAL_RESULT, stylesheetTree.getBaseIdentifier(), lineNumber, columnNumber), m_isWhitespace(isXMLWhitespace(ch, start, length)), // Always null-terminate our buffer, since we may need it that way. m_ch(constructionContext.allocateXalanDOMCharVector(ch + start, length, true)), m_length(length) { disableOutputEscaping(fDisableOutputEscaping); preserveSpace(fPreserveSpace); }
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); }
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); } }
void NamespacesHandler::processExtensionElementPrefixes( StylesheetConstructionContext& theConstructionContext, const XalanDOMChar* theValue, const NamespacesStackType& theCurrentNamespaces) { typedef StylesheetConstructionContext::GetAndReleaseCachedString GetAndReleaseCachedString; StringTokenizer tokenizer( theValue, Constants::DEFAULT_WHITESPACE_SEPARATOR_STRING); const GetAndReleaseCachedString theGuard(theConstructionContext); XalanDOMString& thePrefix = theGuard.get(); while(tokenizer.hasMoreTokens() == true) { tokenizer.nextToken(thePrefix); if(equalsIgnoreCaseASCII(thePrefix, Constants::ATTRVAL_DEFAULT_PREFIX) == true) { thePrefix.clear(); } const XalanDOMString* const theNamespace = XalanQName::getNamespaceForPrefix(theCurrentNamespaces, thePrefix); if(theNamespace == 0) { GetAndReleaseCachedString theGuard(theConstructionContext); theConstructionContext.error( XalanMessageLoader::getMessage( theGuard.get(), XalanMessages::PrefixIsNotDeclared_1Param, thePrefix)); } assert(theNamespace != 0); m_extensionNamespaceURIs.push_back(&theConstructionContext.getPooledString(*theNamespace)); } }
void NamespacesHandler::processExcludeResultPrefixes( StylesheetConstructionContext& theConstructionContext, const XalanDOMString& theElementPrefix, const PrefixChecker* prefixChecker) { if (m_excludedResultPrefixes.empty() == false) { NamespaceExtendedVectorType::iterator i = m_namespaceDeclarations.begin(); // Check for any result prefixes we should exclude... while(i != m_namespaceDeclarations.end()) { const Namespace& theNamespace = *i; const XalanDOMString& thePrefix = theNamespace.getPrefix(); const XalanDOMString& theURI = theNamespace.getURI(); // We can never exclude the prefix of our owner element, so // check that first... if (equals(thePrefix, theElementPrefix) == false && (prefixChecker == 0 || prefixChecker->isActive(thePrefix) == false) && (isExcludedNamespaceURI(theURI) == true || isExtensionNamespaceURI(theURI) == true)) { // Add it to the excluded prefixes, in case we need it later... m_excludedResultPrefixes.push_back( NamespacesVectorType::value_type( theConstructionContext.getPooledString(thePrefix), theConstructionContext.getPooledString(theURI))); // It's excluded, so remove it... i = m_namespaceDeclarations.erase(i); } else { ++i; } } } }
void NamespacesHandler::processExcludeResultPrefixes( StylesheetConstructionContext& theConstructionContext, const XalanDOMChar* theValue, const NamespacesStackType& theCurrentNamespaces) { typedef StylesheetConstructionContext::GetAndReleaseCachedString GetAndReleaseCachedString; StringTokenizer tokenizer( theValue, Constants::DEFAULT_WHITESPACE_SEPARATOR_STRING); const GetAndReleaseCachedString theGuard(theConstructionContext); XalanDOMString& thePrefix = theGuard.get(); while(tokenizer.hasMoreTokens() == true) { tokenizer.nextToken(thePrefix); if(equalsIgnoreCaseASCII(thePrefix, Constants::ATTRVAL_DEFAULT_PREFIX) == true) { thePrefix.clear(); } const XalanDOMString* const theNamespaceURI = XalanQName::getNamespaceForPrefix(theCurrentNamespaces, thePrefix); if(theNamespaceURI == 0) { GetAndReleaseCachedString theGuard(theConstructionContext); theConstructionContext.error( XalanMessageLoader::getMessage( theGuard.get(), XalanMessages::PrefixIsNotDeclared_1Param, thePrefix)); } addOrUpdateByPrefix( theConstructionContext, m_excludedResultPrefixes, thePrefix, *theNamespaceURI); assert(findByPrefix(m_excludedResultPrefixes, thePrefix) != 0 && findByPrefix(m_excludedResultPrefixes, thePrefix)->getURI() == *theNamespaceURI); } }
XALAN_CPP_NAMESPACE_BEGIN /** * Simple string part of a complex AVT. */ AVTPartSimple::AVTPartSimple( StylesheetConstructionContext& constructionContext, const XalanDOMChar* val, XalanDOMString::size_type len) : AVTPart(), m_val(constructionContext.allocateXalanDOMCharVector(val, len, false)), m_len(len) { }
ElemLiteralResult::ElemLiteralResult( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const XalanDOMChar* name, const AttributeListType& atts, int lineNumber, int columnNumber, int xslToken) : ElemUse(constructionContext, stylesheetTree, lineNumber, columnNumber, xslToken), m_elementName(constructionContext.getPooledString(name)), m_avts(0), m_avtsCount(0) { init(constructionContext, stylesheetTree, name, atts); }
void NamespacesHandler::createResultAttributeNames(StylesheetConstructionContext& theConstructionContext) { // Go through all of the result namespaces and create the attribute // name that will be used when they're written to the result tree. // This is more efficient if the stylesheet is used multiple times. if (m_namespaceDeclarations.empty() == false) { const NamespaceExtendedVectorType::iterator theEnd = m_namespaceDeclarations.end(); NamespaceExtendedVectorType::iterator i = m_namespaceDeclarations.begin(); StylesheetConstructionContext::GetAndReleaseCachedString theGuard(theConstructionContext); XalanDOMString& theName = theGuard.get(); for(; i != theEnd; ++i) { NamespaceExtended& theNamespace = *i; const XalanDOMString& thePrefix = theNamespace.getPrefix(); if (isEmpty(thePrefix) == false) { // Create a name of the form xmlns:prefix, where "prefix" is the // text of the prefix. // Reserve the appropriate amount of space in the string. reserve(theName, DOMServices::s_XMLNamespaceWithSeparatorLength + length(thePrefix) + 1); theName = DOMServices::s_XMLNamespaceWithSeparator; theName += thePrefix; theNamespace.setResultAttributeName(theConstructionContext.getPooledString(theName)); } else { // It's the default namespace... theNamespace.setResultAttributeName(DOMServices::s_XMLNamespace); } } } }
XALAN_CPP_NAMESPACE_BEGIN ElemLiteralResult::ElemLiteralResult( StylesheetConstructionContext& constructionContext, Stylesheet& stylesheetTree, const XalanDOMChar* name, const AttributeListType& atts, int lineNumber, int columnNumber) : ElemUse(constructionContext, stylesheetTree, lineNumber, columnNumber, StylesheetConstructionContext::ELEMNAME_LITERAL_RESULT), m_elementName(constructionContext.getPooledString(name)), m_avts(0), m_avtsCount(0) { init(constructionContext, stylesheetTree, name, atts); }
bool ElemLiteralResult::isAttrOK( const XalanDOMChar* attrName, const AttributeListType& /* atts */, int /* which */, StylesheetConstructionContext& constructionContext) const { bool isAttrOK = equals(attrName, DOMServices::s_XMLNamespace) || startsWith(attrName, DOMServices::s_XMLNamespaceWithSeparator); if(isAttrOK == false) { const XalanDOMString::size_type len = length(attrName); const XalanDOMString::size_type indexOfNSSep = indexOf(attrName, XalanUnicode::charColon); if(indexOfNSSep >= len) { // An empty namespace is OK. isAttrOK = true; } else { const StylesheetConstructionContext::GetAndReleaseCachedString theGuard(constructionContext); XalanDOMString& thePrefix = theGuard.get(); thePrefix.assign(attrName, indexOfNSSep); const XalanDOMString* const ns = getStylesheet().getNamespaceForPrefixFromStack(thePrefix); if (ns != 0 && equals(*ns, constructionContext.getXSLTNamespaceURI()) == false) { isAttrOK = true; } } } return isAttrOK; }
void AVT::nextToken( StylesheetConstructionContext& constructionContext, const LocatorType* locator, StringTokenizer& tokenizer, XalanDOMString& token) { if (tokenizer.hasMoreTokens() == false) { GetCachedString theGuard(constructionContext); constructionContext.error( XalanMessageLoader::getMessage( theGuard.get(), XalanMessages::AttributeValueTemplateHasMissing), 0, locator); } else { tokenizer.nextToken(token); } }
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); }
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); } }
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); } }
/** * Construct an AVT by parsing the string, and either * constructing a vector of AVTParts, or simply hold * on to the string if the AVT is simple. */ AVT::AVT( StylesheetConstructionContext& constructionContext, const LocatorType* locator, const XalanDOMChar* name, const XalanDOMChar* stringedValue, const PrefixResolver& resolver) : m_parts(0), m_partsSize(0), m_simpleString(0), m_simpleStringLength(0), m_name(constructionContext.getPooledString(name)) { StringTokenizer tokenizer(stringedValue, theTokenDelimiterCharacters, true); const StringTokenizer::size_type nTokens = tokenizer.countTokens(); if(nTokens < 2) { // Do the simple thing m_simpleStringLength = length(stringedValue); m_simpleString = constructionContext.allocateXalanDOMCharVector(stringedValue, m_simpleStringLength, false); } else { // This over-allocates, but we probably won't waste that much space. If necessary, // we could tokenize twice, just counting the numbers of AVTPart instances we // will need the first time. m_parts = constructionContext.allocateAVTPartPointerVector(nTokens + 1); XalanDOMString buffer(constructionContext.getMemoryManager()); XalanDOMString exprBuffer(constructionContext.getMemoryManager()); XalanDOMString t(constructionContext.getMemoryManager()); // base token XalanDOMString lookahead(constructionContext.getMemoryManager()); // next token while(tokenizer.hasMoreTokens()) { if(length(lookahead)) { t = lookahead; clear(lookahead); } else { nextToken(constructionContext, locator, tokenizer, t); } if(length(t) == 1) { const XalanDOMChar theChar = charAt(t, 0); switch(theChar) { case(XalanUnicode::charLeftCurlyBracket): { // Attribute Value Template start nextToken(constructionContext, locator, tokenizer, lookahead); if(equals(lookahead, theLeftCurlyBracketString)) { // Double braces mean escape to show brace append(buffer, lookahead); clear(lookahead); break; // from switch } else { if(length(buffer) > 0) { assert(m_partsSize + 1 < nTokens); m_parts[m_partsSize++] = constructionContext.createAVTPart( c_wstr(buffer), length(buffer)); clear(buffer); } clear(exprBuffer); while(length(lookahead) > 0 && !equals(lookahead, theRightCurlyBracketString)) { if(length(lookahead) == 1) { switch(charAt(lookahead, 0)) { case XalanUnicode::charApostrophe: case XalanUnicode::charQuoteMark: { // String start append(exprBuffer, lookahead); const XalanDOMChar quote[2] = { lookahead[0], 0 }; // Consume stuff 'till next quote nextToken(constructionContext, locator, tokenizer, lookahead); while(!equals(lookahead, quote)) { append(exprBuffer, lookahead); nextToken(constructionContext, locator, tokenizer, lookahead); } append(exprBuffer,lookahead); break; } case XalanUnicode::charLeftCurlyBracket: { GetCachedString theGuard(constructionContext); // What's another brace doing here? constructionContext.error( XalanMessageLoader::getMessage( theGuard.get(), XalanMessages::LeftBraceCannotAppearWithinExpression), 0, locator); break; } default: // part of the template stuff, just add it. append(exprBuffer, lookahead); break; } // end inner switch } // end if lookahead length == 1 else { // part of the template stuff, just add it. append(exprBuffer,lookahead); } nextToken(constructionContext, locator, tokenizer, lookahead); } // end while(!equals(lookahead, "}")) assert(equals(lookahead, theRightCurlyBracketString)); // Proper close of attribute template. Evaluate the // expression. clear(buffer); assert(m_partsSize + 1 < nTokens); m_parts[m_partsSize++] = constructionContext.createAVTPart( locator, c_wstr(exprBuffer), length(exprBuffer), resolver); clear(lookahead); // breaks out of inner while loop } break; } case(XalanUnicode::charRightCurlyBracket): { nextToken(constructionContext, locator, tokenizer, lookahead); if(equals(lookahead, theRightCurlyBracketString)) { // Double brace mean escape to show brace append(buffer, lookahead); clear(lookahead); // swallow } else { GetCachedString theGuard(constructionContext); constructionContext.error( XalanMessageLoader::getMessage( theGuard.get(), XalanMessages::UnmatchedWasFound), 0, locator); } break; } default: { // Anything else just add to string. append(buffer, theChar); } } // end switch t } // end if length == 1 else { // Anything else just add to string. append(buffer,t); } } // end while(tokenizer.hasMoreTokens()) if(length(buffer) > 0) { assert(m_partsSize + 1 < nTokens); m_parts[m_partsSize++] = constructionContext.createAVTPart(c_wstr(buffer), length(buffer)); clear(buffer); } } // end else nTokens > 1 }