当前位置: 首页>>代码示例>>C++>>正文


C++ Ptr::dmNodeName方法代码示例

本文整理汇总了C++中node::Ptr::dmNodeName方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::dmNodeName方法的具体用法?C++ Ptr::dmNodeName怎么用?C++ Ptr::dmNodeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node::Ptr的用法示例。


在下文中一共展示了Ptr::dmNodeName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createSequence

Sequence FunctionLocalname::createSequence(DynamicContext* context, int flags) const
{
  XPath2MemoryManager* memMgr = context->getMemoryManager();

  Node::Ptr ctxNode;
  if(getNumArgs() == 1) {
    Sequence arg=getParamNumber(1,context)->toSequence(context);
    if(arg.isEmpty())
      return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
    ctxNode=arg.first();
  }
  else {
    const Item::Ptr item = context->getContextItem();
    if(item==NULLRCP)
      XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("Undefined context item in fn:local-name [err:XPDY0002]"));
    if(!item->isNode())
      XQThrow(FunctionException, X("FunctionLocalName::createSequence"),X("The context item is not a node [err:XPTY0004]"));
    ctxNode=item;
	}

  ATQNameOrDerived::Ptr name = ctxNode->dmNodeName(context);
  if(name.notNull())
    return Sequence(context->getItemFactory()->createString(((const ATQNameOrDerived*)name.get())->getName(), context), memMgr);

  return Sequence(context->getItemFactory()->createString(XERCES_CPP_NAMESPACE_QUALIFIER XMLUni::fgZeroLenString, context), memMgr);
}
开发者ID:kanbang,项目名称:Colt,代码行数:26,代码来源:FunctionLocalname.cpp

示例2: assert

bool SequenceType::ItemType::matchesSchemaElement(const Node::Ptr &toBeTested, const DynamicContext* context) const
{
  // retrieve the type of the element name
  assert(m_pName!=NULL);
  const XMLCh* elementNS=m_NameURI;
  const XMLCh* elementName=m_pName->getName();
  SchemaElementDecl *elemDecl=context->getDocumentCache()->getElementDecl(elementNS, elementName);
  assert(elemDecl != NULL);

  // 1. The name of the candidate node matches the specified ElementName or matches the name of an element in a 
  //    substitution group headed by an element named ElementName.
  ATQNameOrDerived::Ptr name = toBeTested->dmNodeName(context);
  if(name.isNull()) return false;
  const XMLCh *node_uri = ((const ATQNameOrDerived*)name.get())->getURI();
  const XMLCh *node_name = ((const ATQNameOrDerived*)name.get())->getName();

  if(!(XPath2Utils::equals(elementName, node_name)) ||
     !(XPath2Utils::equals(elementNS, node_uri)))
  {
    // the node doesn't match the ElementName; check if it is in its substitution group
    SchemaElementDecl* thisElemDecl=context->getDocumentCache()->getElementDecl(node_uri, node_name);
    if(thisElemDecl==NULL) // the node to be tested has no type info
      return false;

    SchemaElementDecl* rootElemDecl=thisElemDecl->getSubstitutionGroupElem();
    bool foundIt=false;
    while (rootElemDecl)
    {
      if (XPath2Utils::equals(rootElemDecl->getBaseName(), elementName) &&
          XPath2Utils::equals(context->getDocumentCache()->getSchemaUri(rootElemDecl->getURI()), elementNS))
      {
        foundIt = true;
        break;
      }

      rootElemDecl = rootElemDecl->getSubstitutionGroupElem();
    }
    if(!foundIt)
      return false;
  }

  // 2. derives-from(AT, ET) is true, where AT is the type of the candidate node and ET is the type declared for 
  //    element ElementName in the in-scope element declarations.
  ComplexTypeInfo* pTypeInfo=elemDecl->getComplexTypeInfo();
  if(pTypeInfo && !toBeTested->hasInstanceOfType(pTypeInfo->getTypeUri(), pTypeInfo->getTypeLocalName(), context))
    return false;

  // 3. Either the nilled property of the candidate node is false, or the element declaration for ElementName in 
  //    the in-scope element declarations is nillable.
  if(toBeTested->dmNilled(context).get()->isTrue() &&
     !(elemDecl->getMiscFlags() & SchemaSymbols::XSD_NILLABLE))
    return false;
      
  return true;
}
开发者ID:kanbang,项目名称:Colt,代码行数:55,代码来源:SequenceType.cpp

示例3: matchesSchemaElement

bool SequenceType::ItemType::matches(const Node::Ptr &toBeTested, DynamicContext* context) const
{
  switch(m_nTestType) {
    case TEST_ELEMENT:
    {
      if(toBeTested->dmNodeKind() != Node::element_string)
        return false;

      if(!matchesNameType(toBeTested, context))
        return false;

      // if the element has xsi:nil="true", m_bAllowNil MUST be true
      if(toBeTested->dmNilled(context)->isTrue() && !m_bAllowNil)
        return false;

      return true;
    }

    case TEST_ATTRIBUTE:
    {
      if(toBeTested->dmNodeKind() != Node::attribute_string)
        return false;
      if(!matchesNameType(toBeTested, context))
        return false;
      return true;
    }

    case TEST_SCHEMA_ELEMENT:
    {
      if(toBeTested->dmNodeKind() != Node::element_string)
        return false;

      return matchesSchemaElement(toBeTested, context);
    }

    case TEST_SCHEMA_ATTRIBUTE:
    {
      if(toBeTested->dmNodeKind() != Node::attribute_string)
        return false;

      // retrieve the type of the attribute name
      assert(m_pName!=NULL);
      const XMLCh* attributeNS=m_NameURI;
      const XMLCh* attributeName=m_pName->getName();
      SchemaAttDef* attrDecl=context->getDocumentCache()->getAttributeDecl(attributeNS, attributeName);
      assert(attrDecl != NULL);

      // 1. The name of the candidate node matches the specified AttributeName
      ATQNameOrDerived::Ptr name = toBeTested->dmNodeName(context);
      if(name.isNull()) return false;
      const XMLCh *node_uri = ((const ATQNameOrDerived*)name.get())->getURI();
      const XMLCh *node_name = ((const ATQNameOrDerived*)name.get())->getName();

      if(!(XPath2Utils::equals(attributeName, node_name)) ||
         !(XPath2Utils::equals(attributeNS, node_uri)))
        return false;

      // 2. derives-from(AT, ET) is true, where AT is the type of the candidate node and ET is the type declared 
      //    for attribute AttributeName in the in-scope attribute declarations.
      DatatypeValidator* pDV=attrDecl->getDatatypeValidator();
      if(pDV && !toBeTested->hasInstanceOfType(pDV->getTypeUri(), pDV->getTypeLocalName(), context))
        return false;

      return true;
    }

    case TEST_PI:
    {
      if(toBeTested->dmNodeKind() != Node::processing_instruction_string)
        return false;
      if(!matchesNameType(toBeTested, context))
        return false;
      return true;
    }

    case TEST_COMMENT:
    {
      return (toBeTested->dmNodeKind() == Node::comment_string);
    }

    case TEST_TEXT:
    {
      return (toBeTested->dmNodeKind() == Node::text_string);
    }

    case TEST_SCHEMA_DOCUMENT:
    case TEST_DOCUMENT:
    {
        if(toBeTested->dmNodeKind() != Node::document_string)
          return false;

        if(m_pName == NULL && m_pType == NULL)
          return true;

        // if we have a constraint on name/type, they apply to the document element
        Result children = toBeTested->dmChildren(context, 0);
        Node::Ptr docElement;
        while((docElement = children->next(context)).notNull() &&
              docElement->dmNodeKind() != Node::element_string) {}

//.........这里部分代码省略.........
开发者ID:kanbang,项目名称:Colt,代码行数:101,代码来源:SequenceType.cpp


注:本文中的node::Ptr::dmNodeName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。