XML/XSLT stylesheet/non xml
Convert non-xml file
<source lang="xml">
File: Data.ini name = A server = B role = C initial screen = D File: Transform.xslt <?xml version="1.0"?> <xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:param name="sourceUri" as="xs:string" /> <xsl:template name="main"> <xsl:variable name="iniFile" select="unparsed-text($sourceUri)" /> <config> <xsl:analyze-string select="$iniFile" regex="\n"> <xsl:non-matching-substring> <item> <xsl:for-each select="tokenize(., "\s*=\s*")"> <xsl:choose> <xsl:when test="position() = 1"> <xsl:attribute name="name"> <xsl:value-of select="." /> </xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:value-of select="." /> </xsl:otherwise> </xsl:choose> </xsl:for-each> </item> </xsl:non-matching-substring> </xsl:analyze-string> </config> </xsl:template>
</xsl:stylesheet>
</source>