|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] WDDX Recordset generic simplification
Hi all,
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. Here is the contents of a file called party.wddx: <?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> And here is the stylesheet referenced <?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></xsl:stylesheet> The output I am current getting is as follows: <?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> The output I am hoping to get is: <?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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







