xsl-list
[Top] [All Lists]

Re: [xsl] Creating child elements to existing Parent elements

2006-09-07 08:50:29

My XSLT would create element <Ingredients> when processing <Spices>.
Later on it should only create <ingredient> element as child element
to <Ingredients> element when processing <Meat> or <Vegetable>. Any
suggestion on how this can be achieved?

You are thinking too procedurally and assuming a particular execution
order. Rather than assume that the Spice elements (not tags, XSLT has no
access to the tags in the original document) are processed first and
then try to "ammend" the element generated when you come to the Meat
element, just define what the content of Ingredients needs to be,
wherever it comes from the document, something like

<Ingredients>
  <xsl:for-each
  select="/x/Spices/Spice|/x/MeatsParentTags/Meat|/x/Vegetables/Vegetable">
  <Ingredient>
   <xsl:copy-of select="@*"/>
  </Ingredient>
  </xsl:for-each>
</Ingredients>

David




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>