gpt4 book ai didi

org.metawidget.util.XmlUtils.combineElements()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 22:31:05 28 4
gpt4 key购买 nike

本文整理了Java中org.metawidget.util.XmlUtils.combineElements()方法的一些代码示例,展示了XmlUtils.combineElements()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtils.combineElements()方法的具体详情如下:
包路径:org.metawidget.util.XmlUtils
类名称:XmlUtils
方法名:combineElements

XmlUtils.combineElements介绍

[英]Combine the attributes and child elements of the second element into the first element.

Combining is performed purely by matching a topLevelAttributeToCombineOn attribute on the element. The child element ordering of the first element is respected.

Child elements are matched recursively on childAttributeToCombineOn.
[中]将第二个元素的属性和子元素组合到第一个元素中。
合并纯粹通过匹配元素上的topLevelAttributeToCombineOn属性来执行。第一个元素的子元素顺序得到尊重。
子元素在childAttributeToCombineOn上递归匹配。

代码示例

代码示例来源:origin: org.metawidget.modules/metawidget-core

protected Document combineInspectionResult( Document masterDocument, Document inspectionDocument ) {

    // Short circuit...

    if ( inspectionDocument == null || !inspectionDocument.hasChildNodes() ) {
      return masterDocument;
    }

    if ( masterDocument == null || !masterDocument.hasChildNodes() ) {
      return inspectionDocument;
    }

    // ...or full combine

    XmlUtils.combineElements( masterDocument.getDocumentElement(), inspectionDocument.getDocumentElement(), TYPE, NAME );
    return masterDocument;
  }
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

protected Document combineInspectionResult( Document masterDocument, Document inspectionDocument ) {

    // Short circuit...

    if ( inspectionDocument == null || !inspectionDocument.hasChildNodes() ) {
      return masterDocument;
    }

    if ( masterDocument == null || !masterDocument.hasChildNodes() ) {
      return inspectionDocument;
    }

    // ...or full combine

    XmlUtils.combineElements( masterDocument.getDocumentElement(), inspectionDocument.getDocumentElement(), TYPE, NAME );
    return masterDocument;
  }
}

代码示例来源:origin: org.metawidget.modules/metawidget-core

combineElements( masterChild, childToAdd, childAttributeToCombineOn, childAttributeToCombineOn );
continue outerLoop;

代码示例来源:origin: org.metawidget.modules/metawidget-all

combineElements( masterChild, childToAdd, childAttributeToCombineOn, childAttributeToCombineOn );
continue outerLoop;

代码示例来源:origin: org.metawidget.modules/metawidget-all

@Override
protected Element getDocumentElement( ResourceResolver resolver, InputStream... files )
  throws Exception {
  Document document = XmlUtils.newDocument();
  Element root = document.createElement( FORMSET_ELEMENT );
  document.appendChild( root );
  for ( InputStream file : files ) {
    Document documentParsed = XmlUtils.parse( file );
    Element formSet = XmlUtils.getChildNamed( documentParsed.getDocumentElement(), FORMSET_ELEMENT );
    if ( formSet == null ) {
      continue;
    }
    XmlUtils.combineElements( root, formSet, getTopLevelTypeAttribute(), getNameAttribute() );
  }
  return root;
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

@Override
protected Element getDocumentElement( ResourceResolver resolver, InputStream... files )
  throws Exception {
  Document document = XmlUtils.newDocument();
  Element root = document.createElement( FORM_BEANS_ELEMENT );
  document.appendChild( root );
  for ( InputStream file : files ) {
    Document documentParsed = XmlUtils.parse( file );
    Element formBeans = XmlUtils.getChildNamed( documentParsed.getDocumentElement(), FORM_BEANS_ELEMENT );
    if ( formBeans == null ) {
      continue;
    }
    XmlUtils.combineElements( root, formBeans, getTopLevelTypeAttribute(), getNameAttribute() );
  }
  return root;
}

代码示例来源:origin: org.metawidget.modules/metawidget-core

/**
 * Merge the given DOM Documents into a single Document, and return its root.
 */
protected Element getDocumentElement( Document... documents )
  throws Exception {
  Document documentMaster = null;
  for ( Document document : documents ) {
    if ( !document.hasChildNodes() ) {
      continue;
    }
    preprocessDocument( document );
    if ( documentMaster == null || !documentMaster.hasChildNodes() ) {
      documentMaster = document;
      continue;
    }
    XmlUtils.combineElements( documentMaster.getDocumentElement(), document.getDocumentElement(), getTopLevelTypeAttribute(), getNameAttribute() );
  }
  if ( documentMaster == null ) {
    return null;
  }
  return documentMaster.getDocumentElement();
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

/**
 * Merge the given DOM Documents into a single Document, and return its root.
 */
protected Element getDocumentElement( Document... documents )
  throws Exception {
  Document documentMaster = null;
  for ( Document document : documents ) {
    if ( !document.hasChildNodes() ) {
      continue;
    }
    preprocessDocument( document );
    if ( documentMaster == null || !documentMaster.hasChildNodes() ) {
      documentMaster = document;
      continue;
    }
    XmlUtils.combineElements( documentMaster.getDocumentElement(), document.getDocumentElement(), getTopLevelTypeAttribute(), getNameAttribute() );
  }
  if ( documentMaster == null ) {
    return null;
  }
  return documentMaster.getDocumentElement();
}

代码示例来源:origin: org.metawidget.modules/metawidget-core

/**
 * Inspect the <code>toInspect</code> for properties and actions.
 * <p>
 * This method can be overridden by clients wishing to modify the inspection process. Most
 * clients will find it easier to override one of the sub-methods, such as
 * <code>inspectTrait</code> or <code>inspectProperty</code>.
 */
protected void inspectTraits( Element toInspect, Element toAddTo ) {
  if ( toInspect == null ) {
    return;
  }
  Document document = toAddTo.getOwnerDocument();
  // Do 'extends' attribute first
  String extendsAttribute = getExtendsAttribute();
  if ( extendsAttribute != null ) {
    if ( toInspect.hasAttribute( extendsAttribute ) ) {
      inspectTraits( (Element) traverse( null, toInspect.getAttribute( extendsAttribute ), false ).getValue(), toAddTo );
    }
  }
  // Next, inspect each child...
  Element element = document.createElementNS( NAMESPACE, ENTITY );
  inspectTraitSiblings( element, XmlUtils.getFirstChildElement( toInspect ) );
  // ...and combine them all. Note the element may already exist from the superclass,
  // and its attributes will get overridden by the subclass
  XmlUtils.combineElements( toAddTo, element, NAME, NAME );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

/**
 * Inspect the <code>toInspect</code> for properties and actions.
 * <p>
 * This method can be overridden by clients wishing to modify the inspection process. Most
 * clients will find it easier to override one of the sub-methods, such as
 * <code>inspectTrait</code> or <code>inspectProperty</code>.
 */
protected void inspectTraits( Element toInspect, Element toAddTo ) {
  if ( toInspect == null ) {
    return;
  }
  Document document = toAddTo.getOwnerDocument();
  // Do 'extends' attribute first
  String extendsAttribute = getExtendsAttribute();
  if ( extendsAttribute != null ) {
    if ( toInspect.hasAttribute( extendsAttribute ) ) {
      inspectTraits( (Element) traverse( null, toInspect.getAttribute( extendsAttribute ), false ).getValue(), toAddTo );
    }
  }
  // Next, inspect each child...
  Element element = document.createElementNS( NAMESPACE, ENTITY );
  inspectTraitSiblings( element, XmlUtils.getFirstChildElement( toInspect ) );
  // ...and combine them all. Note the element may already exist from the superclass,
  // and its attributes will get overridden by the subclass
  XmlUtils.combineElements( toAddTo, element, NAME, NAME );
}

代码示例来源:origin: org.metawidget.modules/metawidget-all

XmlUtils.combineElements( documentMaster.getDocumentElement(), parsed, getTopLevelTypeAttribute(), getNameAttribute() );

代码示例来源:origin: org.metawidget.modules/metawidget-all

protected Element inspect() {
  TypeAndNames typeAndNames = PathUtils.parsePath( mPath, StringUtils.SEPARATOR_DOT_CHAR );
  String type = typeAndNames.getType();
  // Inspect using the 'raw' type (eg. contactForm)
  Element inspectionResult = mPipeline.inspectAsDom( null, type, typeAndNames.getNamesAsArray() );
  // (pageContext may be null in unit tests)
  if ( pageContext != null ) {
    // Try to locate the runtime bean. This allows some Inspectors
    // to act on it polymorphically.
    Object obj = pageContext.findAttribute( type );
    if ( obj != null ) {
      Element additionalInspectionResult = mPipeline.inspectAsDom( obj, obj.getClass().getName(), typeAndNames.getNamesAsArray() );
      // Combine the subtrees
      //
      // Note the top-level types attribute will be different, because one is the 'raw'
      // type (eg. contactForm) and one the runtime bean (eg.
      // org.metawidget.example.struts.addressbook.form.BusinessContactForm)
      if ( inspectionResult == null ) {
        inspectionResult = additionalInspectionResult;
      } else if ( additionalInspectionResult != null ) {
        Element inspectionResultEntity = XmlUtils.getFirstChildElement( inspectionResult );
        Element additionalInspectionResultEntity = XmlUtils.getFirstChildElement( additionalInspectionResult );
        XmlUtils.combineElements( inspectionResultEntity, additionalInspectionResultEntity, NAME, null );
      }
    }
  }
  return inspectionResult;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com