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


Golang Element.Children方法代码示例

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


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

示例1: parseComplexType

// http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/structures.html#element-complexType
func (s *Schema) parseComplexType(root *xmltree.Element) *ComplexType {
	var t ComplexType
	var doc annotation
	t.Name = root.ResolveDefault(root.Attr("", "name"), s.TargetNS)
	t.Abstract = parseBool(root.Attr("", "abstract"))
	// We set this special attribute in a pre-processing step.
	t.Anonymous = (root.Attr("", "_isAnonymous") == "true")

	walk(root, func(el *xmltree.Element) {
		switch el.Name.Local {
		case "annotation":
			doc = doc.append(parseAnnotation(el))
		case "simpleContent":
			t.parseSimpleContent(s.TargetNS, el)
		case "complexContent":
			t.parseComplexContent(s.TargetNS, el)
		default:
			// a complex type defined without any simpleContent or
			// complexContent is interpreted as shorthand for complex
			// content that restricts anyType.
			children := root.Children
			root.Children = nil

			restrict := *root
			restrict.StartElement = xml.StartElement{
				Name: xml.Name{schemaNS, "restriction"},
			}
			restrict.SetAttr("", "base", restrict.Prefix(AnyType.Name()))
			restrict.Children = children

			content := *root
			content.StartElement = xml.StartElement{
				Name: xml.Name{schemaNS, "complexContent"},
			}
			content.Children = []xmltree.Element{restrict}
			root.Children = []xmltree.Element{content}

			t.parseComplexContent(s.TargetNS, &content)
		}
	})
	t.Doc += string(doc)
	return &t
}
开发者ID:DrGo,项目名称:go-xml,代码行数:44,代码来源:parse.go


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