CURRENT PROJECTS
loading
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="*/*"> <xsl:if test="contains(name(), 'data')"> [<xsl:for-each select="*"> {<xsl:if test="contains(name(), 'row')"> <xsl:for-each select="@*"> <xsl:value-of disable-output-escaping="yes" select="name()"/>:'<xsl:call-template name="escape-single-quote"><xsl:with-param name="text" select="."/></xsl:call-template>'<xsl:if test="not(position()=last())">,</xsl:if> </xsl:for-each> </xsl:if>}<xsl:if test="not(position()=last())">,</xsl:if> </xsl:for-each> ] </xsl:if> </xsl:for-each> </xsl:template> <xsl:template name="escape-single-quote"> <xsl:param name="text"/> <xsl:variable name="delimeter">'</xsl:variable> <xsl:variable name="padded-delimeter" select="concat('\',$delimeter)"/> <xsl:choose> <!-- test if there are any delimeters in the string --> <xsl:when test="contains($text, $delimeter)"> <!-- output the string before this delimeter --> <xsl:value-of disable-output-escaping="yes" select="substring-before($text, $delimeter)"/><xsl:value-of disable-output-escaping="yes" select="$padded-delimeter"/> <!-- recursive call to next block --> <xsl:call-template name="escape-single-quote"><xsl:with-param name="text" select="substring-after($text, $delimeter)"/></xsl:call-template> </xsl:when> <!-- otherwise end the recursion --> <xsl:otherwise> <xsl:value-of disable-output-escaping="yes" select="$text"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
<xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882' xmlns:dt='uuid:C2F41010-65B3-11d1-A29F-00AA00C14882' xmlns:rs='urn:schemas-microsoft-com:rowset' xmlns:z='#RowsetSchema'> <s:Schema id='RowsetSchema'> <s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'> ... removed AttributeType information here ... </s:ElementType> </s:Schema> <rs:data> <z:row guest_no='1808354000000' first_name='JIMBOB' last_name='PALMERSKI' birth_date='1980-06-01T00:00:00' address_id='927000000000' area_code='(555)' phone='121-2121' area_cod2=' ' phone2=' ' address='2443 unit 15''"' city='mammoth lakes''2' state='AK ' zip='12345'/> <z:row guest_no='1750384000000' first_name='WEBOPS' last_name='RULEZ;' birth_date='1981-01-01T00:00:00'/> </rs:data> </xml>
[ { guest_no:'1808354000000', first_name:'JIMBOB', last_name:'PALMERSKI', birth_date:'1980-06-01T00:00:00', address_id:'927000000000', area_code:'(555)', phone:'121-2121', area_cod2:' ', phone2:' ', address:'2443 unit 15\'\'"', city:'mammoth lakes\'\'2', state:'AK ', zip:'12345' }, { guest_no:'1750384000000', first_name:'WEBOPS', last_name:'RULEZ;', birth_date:'1981-01-01T00:00:00' } ]This is glorious for output conversion from the bloated ADODB default XML recordSet - especially when you're not using the ADODB assemblies or are not in the windows environment.