Documentation
¶
Overview ¶
Package xml is part of the go-fastreport library, a pure Go port of FastReport .NET.
Package xml provides an XML data source for go-fastreport. It is the Go equivalent of FastReport.Data.XmlDataConnection.
Index ¶
- type ConnectionStringBuilder
- func (b *ConnectionStringBuilder) Build() string
- func (b *ConnectionStringBuilder) Codepage() int
- func (b *ConnectionStringBuilder) SetCodepage(n int)
- func (b *ConnectionStringBuilder) SetXmlFile(v string)
- func (b *ConnectionStringBuilder) SetXsdFile(v string)
- func (b *ConnectionStringBuilder) XmlFile() string
- func (b *ConnectionStringBuilder) XsdFile() string
- type XMLDataSource
- func (x *XMLDataSource) FilePath() string
- func (x *XMLDataSource) Init() error
- func (x *XMLDataSource) RootPath() string
- func (x *XMLDataSource) RowElement() string
- func (x *XMLDataSource) SetFilePath(path string)
- func (x *XMLDataSource) SetRootPath(path string)
- func (x *XMLDataSource) SetRowElement(name string)
- func (x *XMLDataSource) SetXML(s string)
- func (x *XMLDataSource) XML() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionStringBuilder ¶
type ConnectionStringBuilder struct {
// contains filtered or unexported fields
}
func NewConnectionStringBuilder ¶
func NewConnectionStringBuilder(connectionString string) *ConnectionStringBuilder
func (*ConnectionStringBuilder) Build ¶
func (b *ConnectionStringBuilder) Build() string
Build serialises the builder state to a connection string.
func (*ConnectionStringBuilder) Codepage ¶
func (b *ConnectionStringBuilder) Codepage() int
func (*ConnectionStringBuilder) SetCodepage ¶
func (b *ConnectionStringBuilder) SetCodepage(n int)
SetCodepage sets the code page number.
func (*ConnectionStringBuilder) SetXmlFile ¶
func (b *ConnectionStringBuilder) SetXmlFile(v string)
SetXmlFile sets the path to the XML data file.
func (*ConnectionStringBuilder) SetXsdFile ¶
func (b *ConnectionStringBuilder) SetXsdFile(v string)
SetXsdFile sets the path to the XSD schema file.
func (*ConnectionStringBuilder) XmlFile ¶
func (b *ConnectionStringBuilder) XmlFile() string
func (*ConnectionStringBuilder) XsdFile ¶
func (b *ConnectionStringBuilder) XsdFile() string
type XMLDataSource ¶
type XMLDataSource struct {
data.BaseDataSource
// contains filtered or unexported fields
}
XMLDataSource is a DataSource backed by an XML file or string. It reads a list of repeating child elements and exposes their attributes and child text content as columns.
Configuration:
- SetFilePath / SetXML — source of XML input
- SetRootPath — slash-separated path to the repeating element container e.g. "Customers" finds <Customers> under the root element
- SetRowElement — local name of each row element (default: first child tag)
Column values come from:
- Element attributes: <Item Name="Alice" Age="30"/>
- Child element text: <Item><Name>Alice</Name><Age>30</Age></Item>
func (*XMLDataSource) FilePath ¶
func (x *XMLDataSource) FilePath() string
FilePath returns the XML file path.
func (*XMLDataSource) Init ¶
func (x *XMLDataSource) Init() error
Init reads and parses the XML, populating the row store.
func (*XMLDataSource) RootPath ¶
func (x *XMLDataSource) RootPath() string
RootPath returns the root path.
func (*XMLDataSource) RowElement ¶
func (x *XMLDataSource) RowElement() string
RowElement returns the configured row element name.
func (*XMLDataSource) SetFilePath ¶
func (x *XMLDataSource) SetFilePath(path string)
SetFilePath sets the path to an XML file as the data source.
func (*XMLDataSource) SetRootPath ¶
func (x *XMLDataSource) SetRootPath(path string)
SetRootPath sets a slash-separated path to the container element. e.g. "Customers" finds the first <Customers> child of the root. e.g. "Orders/Items" finds <Items> inside <Orders>.
func (*XMLDataSource) SetRowElement ¶
func (x *XMLDataSource) SetRowElement(name string)
SetRowElement sets the local element name used to identify row elements. If empty, the first child element name under the container is used.
func (*XMLDataSource) SetXML ¶
func (x *XMLDataSource) SetXML(s string)
SetXML sets a raw XML string as the data source.