xslt - How to pick up rows from XML for processing -


i process xml that:

<rows>  <row>   <country>at</country>   <some>element</some>  </row>  <row>   <country>cz</country>   <some>element</some>  </row>  <row>   <country>bg</country>   <some>element</some>  </row>  <row>   <country>cz</country>   <some>element</some>  </row> </rows> 

i have regroup rows target xml in way: first must rows country 'cz', can rows other countries.

i can pick rows country 'cz' in way:

<xsl:key name="countries" match="row" use="country">  <xsl:for-each select="key('countries', 'cz')">  <!-- transformation --> </xsl:for-each> 

but don't know, how pick rows other countries? can use somethink like:

<xsl:for-each select="key('countries', !'cz')"> 

?

edit:

expected output is:

<rows>  <row>   <country>cz</country>   <transformed>element</transformed>  </row>  <row>   <country>cz</country>   <transformed>element</transformed>  </row>  <row>   <country>at</country>   <transformed>element</transformed>  </row>  <row>   <country>bg</country>   <transformed>element</transformed>  </row> </rows> 

order of other rows (except 'cz') not mandatory.

i'm using xslt 1.0, can use xslt 2.0, too.

even without xsl:key.

select cz rows:

<xsl:apply-templates select="//row[country='cz']"/> 

select other rows:

<xsl:apply-templates select="//row[country!='cz']"/> 

you can use same expressions in xsl:for-each well.


Comments