Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

transform node-set into one row using many attributes

Status
Not open for further replies.

mgriffith

MIS
Jul 3, 2001
177
US
anyone know of a way to turn something like

---------------------------------------
<runcard>
<workcenter id=&quot;1&quot; name=&quot;asdf&quot;>
<operation_list layout=&quot;3&quot;>
<operation name=&quot;a&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
<operation name=&quot;b&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
</operation>
<operation_list layout=&quot;2&quot;>
<operation name=&quot;c&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
<operation name=&quot;d&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
</operation>
</workcenter>
<workcenter id=&quot;2&quot; name=&quot;efgh&quot;>
<operation_list layout=5&quot;>
<operation name=&quot;a&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
<operation name=&quot;c&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
</operation>
<operation_list layout=&quot;3&quot;>
<operation name=&quot;a&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
<operation name=&quot;d&quot; type=&quot;b&quot; val=&quot;c&quot; tol=&quot;d&quot;/>
</operation>
</workcenter>
</runcard>
----------------------------------------


into something like


----------------------------------------
<runcard_2>
<operation workcenter_id=&quot;1&quot; workcenter_name=&quot;asdf&quot; operation_list_layout=&quot;3&quot; name=&quot;a&quot; type=&quot;b&quot; ... />
<operation workcenter_id=&quot;1&quot; workcenter_name=&quot;asdf&quot; operation_list_layout=&quot;3&quot; name=&quot;b&quot; type=&quot;b&quot; ... />
<operation workcenter_id=&quot;1&quot; workcenter_name=&quot;asdf&quot; operation_list_layout=&quot;2&quot; name=&quot;c&quot; type=&quot;b&quot; ... />
<operation workcenter_id=&quot;1&quot; workcenter_name=&quot;asdf&quot; operation_list_layout=&quot;2&quot; name=&quot;d&quot; type=&quot;b&quot; ... />
<operation workcenter_id=&quot;2&quot; workcenter_name=&quot;efgh&quot; operation_list_layout=&quot;5&quot; name=&quot;a&quot; type=&quot;b&quot; ... />
...
</runcard_2>
----------------------------------------------

i would like to do this without using a <xsl:attribute/> tag for each attribute in an <operation/> .
i have got something (which seems too simple) that will copy all of the attributes from either /runcard/workcenter/operation_list/operation, /runcard/workcenter/operation_list, or /runcard/workcenter into a new operation, but not all at the same time...here's my xsl for clarity


-----------------------------------------------------
<xsl:template match=&quot;/runcard&quot;>

<runcard_2>
<xsl:for-each select=&quot;workcenter/operation_list/operation&quot; >
<xsl:copy>
<xsl:apply-templates select=&quot;/runcard/workcenter/@*&quot; /> <!--copy all attributes from the workcenter to the new <runcard_2>....this works fine, other than i can't prefix the attributes, but that could be solved by prefixing them in the initial <runcard><workcenter prefix_attribute=&quot;&quot;>-->
<xsl:apply-templates select=&quot;/runcard/workcenter/operation_list/@*&quot; /> <!--this doesn't run unless i put it above the first one, but then the first one doesn't run-->
<xsl:apply-templates select=&quot;/runcard/workcenter/operation_list/operation/@*&quot; /> <!--same with this one...doesn't run unless called first-->
</xsl:copy>
</xsl:for-each>
</runcard_2>

</xsl:template>

<xsl:template match=&quot;runcard/workcenter/operation_list/operation/@*&quot;>
<xsl:copy/>
</xsl:template>

<xsl:template match=&quot;/runcard/workcenter/operation_list/@*&quot;>
<xsl:copy/>
</xsl:template>

<xsl:template match=&quot;/runcard/workcenter/@*&quot;>
<xsl:copy/>
</xsl:template>

--------------------------------------------



thanks for any and all help
mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top