go-xml icon indicating copy to clipboard operation
go-xml copied to clipboard

<xsd:attribute ref="xml:space" use="required"> Reference attribute conversion failed

Open dhbloo opened this issue 1 year ago • 0 comments

The sample code is as follows, the input file name is AUTOSAR_00048.xsd

func MyTestXsdNormalize(filename string) error {
	doc , err := os.ReadFile(filename)
	if err != nil {
		return err
	}
	doctrees, err := xsd.Normalize(doc)
	if err != nil {
		logger.GetLogger().Warningf("Failed to load schema %q: %v", filename, err)
		return err
	}

	// Write to file a.xml
	f, err := os.Create("AUTOSAR_00048_doctrees.xsd")
	for _, t := range doctrees {
		var result = xmltree.MarshalIndent(t, "", "  ")
		f.Write(result)
	}
	f.Close()
}

It was found that some refs were not converted successfully. For example, after converting the input file, the 180055 line of the output file AUTOSAR_00048_doctrees.xsd in the attachment has the following content:

<xsd:attribute ref="xml:space" use="required" type="xsd:anySimpleType"> where the ref="XML:space" should be replaced.

Here is the output file: AUTOSAR_00048_doctrees.zip Here is the input file: AUTOSAR_00048.zip

dhbloo avatar Jul 28 '24 02:07 dhbloo