update at 2023/08/14

This commit is contained in:
2023-08-14 21:41:37 +08:00
parent a039a664f1
commit 44e8cbee2c
255 changed files with 20426 additions and 233 deletions

87
tools/genxml/genxml.go Normal file
View File

@@ -0,0 +1,87 @@
package main
import (
"flag"
"log"
"os/exec"
"strings"
xsd "github.com/metaleap/go-xsd"
)
var (
flagGoFmt = flag.Bool("gofmt", true, "Run 'gofmt' against the generated Go wrapper package?")
flagGoInst = flag.Bool("goinst", true, "Run 'go-buildrun' against the generated Go wrapper package?")
flagSchema = flag.String("uri", "", "The XML Schema Definition file URIs to generate a Go wrapper packages from, whitespace-separated. (For each, the protocol prefix can be omitted, it then defaults to http://. Only protocols understood by the net/http package are supported.)")
flagLocalCopy = flag.Bool("local", true, "Local copy: only downloads if file does not exist locally")
flagForceParse = flag.Bool("parse", false, "Not necessary unless the generated Go wrapper package won't compile.")
flagBasePath = flag.String("basepath", "", "Defaults to "+xsd.PkgGen.BasePath+". A $GOPATH/src/-relative path (always a slash-style path, even on Windows) where XSD files are downloaded to / loaded from and generated Go wrapper packages are created. Any XSD imports are also rewritten as Go imports from that path (but are not otherwise auto-magically processed in any way).")
// if no schemas are specified in *flagSchema, we run the pkg-maker through a default series of various XSDs...
schemas = []string{
"./nrm-schema.xsd",
"www.w3.org/2001/xml.xsd",
"www.w3.org/2001/03/xml.xsd",
"www.w3.org/TR/2002/WD-SVG11-20020108/xml.xsd",
"www.w3.org/TR/2002/WD-SVG11-20020108/xlink.xsd",
"www.w3.org/TR/2002/WD-SVG11-20020108/SVG.xsd",
"www.w3.org/2007/schema-for-xslt20.xsd",
"www.w3.org/Math/XMLSchema/mathml2/common/xlink-href.xsd",
"www.w3.org/Math/XMLSchema/mathml2/mathml2.xsd",
"docs.oasis-open.org/election/external/xAL.xsd",
"docbook.org/xml/5.0/xsd/xml.xsd",
"docbook.org/xml/5.0/xsd/xlink.xsd",
"docbook.org/xml/5.0/xsd/docbook.xsd",
"kbcafe.com/rss/atom.xsd.xml",
"thearchitect.co.uk/schemas/rss-2_0.xsd",
"schemas.opengis.net/kml/2.2.0/atom-author-link.xsd",
"schemas.opengis.net/kml/2.2.0/ogckml22.xsd",
"khronos.org/files/collada_schema_1_4",
"khronos.org/files/collada_schema_1_5",
}
)
func main() {
var (
sd *xsd.Schema
err error
raw []byte
outFilePath string
)
flag.Parse()
if len(*flagSchema) > 0 {
schemas = strings.Split(*flagSchema, " ")
}
if len(*flagBasePath) > 0 {
xsd.PkgGen.BasePath, xsd.PkgGen.BaseCodePath = *flagBasePath, udevgo.GopathSrc(strings.Split(*flagBasePath, "/")...)
}
for _, s := range schemas {
log.Printf("LOAD:\t%v\n", s)
if sd, err = xsd.LoadSchema(s, *flagLocalCopy); err != nil {
log.Printf("\tERROR: %v\n", err)
} else if sd != nil {
xsd.PkgGen.ForceParseForDefaults = *flagForceParse || (s == "schemas.opengis.net/kml/2.2.0/ogckml22.xsd") // KML schema uses 0 and 1 as defaults for booleans...
if outFilePath, err = sd.MakeGoPkgSrcFile(); err == nil {
log.Printf("MKPKG:\t%v\n", outFilePath)
if *flagGoFmt {
if raw, err = exec.Command("gofmt", "-w=true", "-s=true", "-e=true", outFilePath).CombinedOutput(); len(raw) > 0 {
log.Printf("GOFMT:\t%s\n", string(raw))
}
if err != nil {
log.Printf("GOFMT:\t%v\n", err)
}
}
if *flagGoInst {
if raw, err = exec.Command("go-buildrun", "-d=__doc.html", "-f="+outFilePath).CombinedOutput(); len(raw) > 0 {
println(string(raw))
}
if err != nil {
log.Printf("GOINST:\t%v\n", err)
}
}
} else {
log.Printf("\tERROR:\t%v\n", err)
}
}
}
}

View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="DataFile">
<xs:complexType>
<xs:sequence>
<xs:element name="FileHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="TimeStamp" type="xs:dateTime"/>
<xs:element name="TimeZone" type="xs:string"/>
<xs:element name="VendorName" type="xs:string" minOccurs="0"/>
<xs:element name="ElementType" type="xs:string" minOccurs="0"/>
<xs:element name="CmVersion" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Objects" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ObjectType" type="xs:string"/>
<!--该字段必选-->
<xs:element name="FieldName">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="N">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="i" type="xs:integer" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="FieldValue">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Object">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="V">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="i" type="xs:integer" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="rmUID" type="xs:string" use="required"/>
<xs:attribute name="Dn" type="xs:string"/>
<!-- //无线、核心网专业该字段必选传输、IP专业、业务系统无该字段-->
<xs:attribute name="UserLabel" type="xs:string"/>
<!-- //无线、核心网专业该字段必选传输、IP专业、业务系统无该字段-->
<xs:attribute name="PVFlag" type="xs:string" use="required"/>
<!-- //必须-->
<xs:attribute name="VMID" type="xs:string"/>
<!-- //VNF网络或VNF和PNF混合组网虚拟网元必选物理网元无该字段-->
<xs:attribute name="VNFInstanceID" type="xs:string"/>
<!-- //VNF网络或VNF和PNF混合组网虚拟网元必选物理网元无该字段-->
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="PmFile">
<xs:complexType>
<xs:sequence>
<xs:element name="FileHeader">
<xs:complexType>
<xs:sequence>
<xs:element name="TimeStamp" type="xs:dateTime" />
<xs:element name="TimeZone" type="xs:string" />
<xs:element name="Period" type="xs:integer" />
<xs:element name="VendorName" type="xs:string" />
<xs:element name="ElementType" type="xs:string" />
<xs:element name="PmVersion" type="xs:string" />
<xs:element name="StartTime" type="xs:dateTime" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Measurements" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ObjectType" type="xs:string" />
<xs:element name="PmName">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="N">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="i" type="xs:integer" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PmData">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="Object">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="V">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="i" type="xs:integer" use="required" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="CV">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="SN" type="xs:string" />
<xs:element name="SV" type="xs:string" />
</xs:sequence>
<xs:attribute name="i" type="xs:integer"
use="required" />
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="rmUID" type="xs:string" use="required" />
<xs:attribute name="Dn" type="xs:string" use="required" />
<xs:attribute name="UserLabel" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>