Guest NathanPhillips Posted November 3, 2005 Share Posted November 3, 2005 Hi all,I am mapping an XML output of a database to a different XML format. This is what I want to do: I have several <account> elements with the same Company name. The new format needs them all together under one <Company> element.For each element of the <account> type, if it has already been mapped then skip it. If this is the first encounter, mark it as mapped, then map it and all the <account> elements with the same company name.How can I do this marking? Is a variable that I create in a template visible to subsequent instatiations of the same template?Nathan Link to comment Share on other sites More sharing options...
dooberry Posted May 17, 2006 Share Posted May 17, 2006 I've just stumbled across this one which means that you might be able to return the favourSomething like: <xsl:variable name="Cmpny" select="Company" /><company><xsl:value-of select="$Cmpny"/><xsl:for-each select="account[company=$cmpny]"><account><xsl:value-of select="account" /></account></xsl:for-each></company> There'll probably be tweaks to make to this code - I don't think it'll give you unique company names for instance (something you might be able to get round with a primary key in your database, or waiting for XML version 2!), but if my brain is working properly then this should help at least.Looks like you've been waiting a while too! :)Dooberry. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now