Subject: [xsl] WDDX Recordset generic simplification From: "Eric Pheatt" <eric.pheatt@xxxxxxxxx> Date: Fri, 3 Nov 2006 11:31:14 -0800 |
I have an excerpt of a wddx data being generated from query data in ColdFusion 5 and I need to simplify the structure with an intermediate xsl transform so that I can consume the simplified form in a mail merge system. I've looked on the list and I saw a post from 2000 (http://www.biglist.com/lists/xsl-list/archives/200005/msg00879.html) and have implemented something similar, which only sort of works. As you can see, the "structure" is correct, but the values are wrong. I'm having trouble wrapping my head around the push approach, since the mail merge system uses a pull approach, so I fear I am over-complicating things. I may just need better search terms.
I'm using SAXON 6.5.3 via javax in a 1.4.2 java applet, (but not via the XSLTProcessorApplet interface, ) so this needs to be XSLT 1.0.
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xml" href="wddx2party.xsl"?> <wddxPacket version='1.0'><header></header><data><struct> <var name='party'> <recordset rowCount='2' fieldNames='PARTY_ID,PARTY_ROLE_ID,FIRST_NAME,LAST_NAME,BIRTH_DT'> <field name='PARTY_ID'> <number>2127652</number> <number>2127653</number></field> <field name='PARTY_ROLE_ID'> <number>51</number> <number>24</number></field> <field name='FIRST_NAME'> <string>Bob</string> <string>Donte</string></field> <field name='LAST_NAME'> <string>Jones</string> <string>Smith</string></field> <field name='SUFFIX'> <string></string> <string></string></field> <field name='BIRTH_DT'> <string></string> <dateTime>1990-6-4T0:0:0-8:0</dateTime></field> </recordset> </var> <var name='alias'> <recordset rowCount='1' fieldNames='ALIAS_ID,PARTY_ID,FIRST_NAME,LAST_NAME'> <field name='ALIAS_ID'> <number>1</number></field> <field name='PARTY_ID'> <number>2127652</number></field> <field name='FIRST_NAME'> <string>Bobby</string></field> <field name='LAST_NAME'> <string>Joneson</string></field> </recordset> </var> </struct></data></wddxPacket>
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/wddxPacket"> <partyList> <xsl:apply-templates/> </partyList> </xsl:template>
<xsl:template match="var/recordset"> <xsl:for-each select="field[1]/*"> <xsl:element name="{../../../@name}"> <xsl:for-each select="../../field"> <xsl:call-template name="field-row"> <xsl:with-param name="row-no" select="position()"/> </xsl:call-template> </xsl:for-each> </xsl:element> </xsl:for-each> </xsl:template>
<xsl:template name="field-row"> <xsl:param name="row-no"/> <xsl:element name="{@name}"> <xsl:for-each select="child::*[position() = $row-no]"> <xsl:value-of select="text()"/> </xsl:for-each> </xsl:element> </xsl:template>
<?xml version="1.0" encoding="UTF-8"?> <partyList> <party> <PARTY_ID>2127652</PARTY_ID> <PARTY_ROLE_ID>24</PARTY_ROLE_ID> <FIRST_NAME/> <LAST_NAME/> <SUFFIX/> <BIRTH_DT/> </party> <party> <PARTY_ID>2127652</PARTY_ID> <PARTY_ROLE_ID>24</PARTY_ROLE_ID> <FIRST_NAME/> <LAST_NAME/> <SUFFIX/> <BIRTH_DT/> </party> <alias> <ALIAS_ID>1</ALIAS_ID> <PARTY_ID/> <FIRST_NAME/> <LAST_NAME/> </alias> </partyList>
<?xml version="1.0" encoding="UTF-8"?> <partyList> <party> <PARTY_ID>2127652</PARTY_ID> <PARTY_ROLE_ID>51</PARTY_ROLE_ID> <FIRST_NAME>Bob</FIRST_NAME> <LAST_NAME>Jones</LAST_NAME> <SUFFIX/> <BIRTH_DT/> </party> <party> <PARTY_ID>2127653</PARTY_ID> <PARTY_ROLE_ID>24</PARTY_ROLE_ID> <FIRST_NAME>Donte</FIRST_NAME> <LAST_NAME>Smith</LAST_NAME> <SUFFIX/> <BIRTH_DT>1990-6-4T0:0:0-8:0</BIRTH_DT> <alias/> </party> <alias> <ALIAS_ID>1</ALIAS_ID> <PARTY_ID>2127652</PARTY_ID> <FIRST_NAME>Bobby</FIRST_NAME> <LAST_NAME>Joneson</LAST_NAME> </alias> </partyList>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Cals Table, ms | Thread | [xsl] Re: WDDX Recordset generic si, Eric Pheatt |
RE: [xsl] Cals table question, Ian Proudfoot | Date | Re: [xsl] Cals table question, B Tommie Usdin |
Month |