本文整理汇总了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
}