I have a requirement which is to be achieved using xslt. It requires to add only those values of field 'NETWR' under E1EDP01, when another field WERKS under E1EDP01 satisfies a certain condition. This added sum is to be populated under different node field SUMME under E1EDS01 (Occurrence of E1EDS01 is only one). Condition for WERKS is , it must have value = VK10 0r VK11 0r VK12 or (VK13 and IDTNR is not blank). I tried with below XSLT code but it gives me value '0'in output.Could anyone please help?
XSLT I used:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ZNUMBER>
<IDOC>
<xsl:for-each select="Z_MM/IDOC/E1EDS01">
<E1EDS01>
<SUMME>
<xsl:value-of select="sum(Z_MM/IDOC/E1EDP01[(WERKS='VK13' and E1EDP19/IDTNR!='') or WERKS = 'VK10' or WERKS = 'VK11' or WERKS = 'VK12' ]/#NETWR)"/>
</SUMME>
</E1EDS01>
</xsl:for-each>
</IDOC>
</ZNUMBER>
</xsl:template>
</xsl:stylesheet>
INPUT XML:
<?xml version="1.0" encoding="UTF-8"?>
<Z_MM>
<IDOC BEGIN="1">
<E1EDP01 SEGMENT="1">
<NETWR>20</NETWR>
<WERKS>VK13</WERKS>
<E1EDP19 SEGMENT="1">
<IDTNR>000000000000211087</IDTNR>
</E1EDP19>
</E1EDP01>
<E1EDP01 SEGMENT="1">
<NETWR>10</NETWR>
<WERKS>VK11</WERKS>
<E1EDP19 SEGMENT="1">
<QUALF>001</QUALF>
</E1EDP19>
</E1EDP01>
<E1EDS01 SEGMENT="1">
<SUMID>002</SUMID>
<SUMME></SUMME>
<SUNIT></SUNIT>
</E1EDS01>
</IDOC>
</Z_MM>
OUTPUT should come as 20+10=30
Your current sum function is within an xsl:for-each in which you select E1EDS01 elements, so you expression is relative to that. In other words, it is looking for a child element of E1EDS01 called ZM1. If you want to search outside the current element, precede the expression / to start at the document node again. Additionally your expression is currently summing #NEWTR which is an attribute, whereas in your XML it is an element.
Try this expression.
<xsl:value-of select="sum(/Z_MM/IDOC/E1EDP01[(WERKS='VK13' and E1EDP19/IDTNR!='') or WERKS = 'VK10' or WERKS = 'VK11' or WERKS = 'VK12']/NETWR)"/>
Having said that, looking at your current XSLT, you don't really need the xsl:for-each at all in this case, as you say there is only one E1EDS01 and you are not actually using any value in it anyway.
Try this XSLT (The / is not needed here now, because you would already be positioned on the document node).
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ZNUMBER>
<IDOC>
<E1EDS01>
<SUMME>
<xsl:value-of select="sum(Z_MM/IDOC/E1EDP01[(WERKS='VK13' and E1EDP19/IDTNR!='') or WERKS = 'VK10' or WERKS = 'VK11' or WERKS = 'VK12']/NETWR)"/>
</SUMME>
</E1EDS01>
</IDOC>
</ZNUMBER>
</xsl:template>
</xsl:stylesheet>
Alternatively, if you XSLT is a sample, and you actually just want to populate the existing SUMME, you could do this with the identity template, and an extra template to match SUMME.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="SUMME">
<xsl:copy>
<xsl:value-of select="sum(/Z_MM/IDOC/E1EDP01[(WERKS='VK13' and E1EDP19/IDTNR!='') or WERKS = 'VK10' or WERKS = 'VK11' or WERKS = 'VK12']/NETWR)"/>
</xsl:copy>
</xsl:template>
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Related
I wanna read the element count and apply the target xml element from a specific source element.
this is source xml to be read and counting POSEX field
<?xml version="1.0" encoding="UTF-8"?>
<INVOIC01>
<IDOC>
<POSEX>000010</POSEX>
<MENGE>1.000</MENGE>
<MENEE>EA</MENEE>
<GEWEI>KGM</GEWEI>
<BRGEW>13.000</BRGEW>
<PSTYV>TAN</PSTYV>
<WERKS>3000</WERKS>
</IDOC>
<IDOC>
<POSEX>000010</POSEX>
<MENGE>1.000</MENGE>
<MENEE>EA</MENEE>
<GEWEI>KGM</GEWEI>
<BRGEW>13.000</BRGEW>
<PSTYV>TAN</PSTYV>
<WERKS>3000</WERKS>
</IDOC>
</INVOIC01>
my xslt code
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="*"/>
</xsl:template>
<!-- ============================================================================================= -->
<!-- Template: Enter the ordinal number in POSEX-->
<!-- ============================================================================================= -->
<xsl:template match="POSEX">
<D_6066>
<xsl:value-of select="count(preceding::POSEX)+1"/>
</D_6066>
</xsl:template>
</xsl:stylesheet>
outcome xml after run xslt code
<?xml version="1.0" encoding="UTF-8"?>
<D_6066>1</D_6066>
1.000
EA
KGM
13.000
TAN
3000
<D_6066>2</D_6066>
1.000
EA
KGM
13.000
TAN
3000
I want to expect target xml as below after run xslt.
<D_6066>2</D_6066>
If I understand correctly, you want your output document to consist of a single D_6066 element containing the count of the number of POSEX elements in the input document.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<D_6066>
<xsl:value-of select="count(//POSEX)"/>
</D_6066>
</xsl:template>
</xsl:stylesheet>
I'm in big trouble with a task I should fulfill and tryed it for several days now. I would be very grateful to anyone who can help with the solution.
Problem
I need to group values together within a XSL transformation (XSLT 1.0). Of course I searched the forum and web so I found that I have to do it with muenchian grouping. I just can't get managed to get it running on my own.
Filling the field YCSSTKLID with grouped values:
YCSSTKLID need to be filled with a concatenation out of "ESN" + "GRAPHIC_NAME" (e.g '123#1' for ESN '123' and GRAPHIC_NAME '1.png'
Every combination of ESN + GRAPHIC_NAME must only be contained a single time, so the duplicates need to be removed
A ESN can have multiple associated GRAPHIC_NAMES
A GRAPHIC_NAME can belong to multiple ESN
Simplified Source
<?xml version="1.0" encoding="utf-8"?>
<ns:MT_FlatFile_Lists_Cu xmlns:ns="urn:las:pp:ss1:tar">
<Cu_Records>
<Record>
<ESN>123</ESN>
<GRAPHIC_NAME>1.png</GRAPHIC_NAME>
<LEVEL_NO>1</LEVEL_NO>
<CALLOUT></CALLOUT>
</Record>
<Record>
<ESN>123</ESN>
<GRAPHIC_NAME>2.png</GRAPHIC_NAME>
<LEVEL_NO>2</LEVEL_NO>
<CALLOUT></CALLOUT>
</Record>
<Record>
<ESN>123</ESN>
<GRAPHIC_NAME>2.png</GRAPHIC_NAME>
<LEVEL_NO>3</LEVEL_NO>
<CALLOUT>3</CALLOUT>
</Record>
<Record>
<ESN>456</ESN>
<GRAPHIC_NAME>2.png</GRAPHIC_NAME>
<LEVEL_NO>1</LEVEL_NO>
<CALLOUT></CALLOUT>
</Record>
<Record>
<ESN>456</ESN>
<GRAPHIC_NAME>2.png</GRAPHIC_NAME>
<LEVEL_NO>2</LEVEL_NO>
<CALLOUT>17</CALLOUT>
</Record>
<Record>
<ESN>456</ESN>
<GRAPHIC_NAME>3.png</GRAPHIC_NAME>
<LEVEL_NO>2</LEVEL_NO>
<CALLOUT>18</CALLOUT>
</Record>
</Cu_Records>
</ns:MT_FlatFile_Lists_Cu>
Desired Output
<?xml version="1.0" encoding="UTF-8"?>
<YCSMKO01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<SNDPOR></SNDPOR>
<SNDPRT></SNDPRT>
<SNDPRN></SNDPRN>
<SNDLAD></SNDLAD>
</EDI_DC40>
<YCSMOTOR_KONF01 SEGMENT="1">
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>123#1</YCSSTKLID>
</YCSMOTOR_KONF02>
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>123#2</YCSSTKLID>
</YCSMOTOR_KONF02>
</YCSMOTOR_KONF01>
</IDOC>
</YCSMKO01>
<YCSMKO01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<SNDPOR></SNDPOR>
<SNDPRT></SNDPRT>
<SNDPRN></SNDPRN>
<SNDLAD></SNDLAD>
</EDI_DC40>
<YCSMOTOR_KONF01 SEGMENT="1">
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>456#2</YCSSTKLID>
</YCSMOTOR_KONF02>
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>456#3</YCSSTKLID>
</YCSMOTOR_KONF02>
</YCSMOTOR_KONF01>
</IDOC>
</YCSMKO01>
Reduced example XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" xmlns:xsltc="http://xml.apache.org/xalan/xsltc" xmlns:map="java.util.Map" xmlns:dyn="com.sap.aii.mapping.api.DynamicConfiguration" xmlns:key="com.sap.aii.mapping.api.DynamicConfigurationKey" xmlns:ns="urn:las:pp:ss1:tar" exclude-result-prefixes="xs ns xsl map key dyn xsltc">
<xsl:output indent="yes"/>
<xsl:key name="a" match="Record" use="ESN"/>
<xsl:key name="grouping" match="/ns:MT_FlatFile_Lists_Cu/Cu_Records/Record" use="concat(./ESN, ./GRAPHIC_NAME)"/>
<xsl:template match="/">
<xsl:apply-templates select="/ns:MT_FlatFile_Lists_Cu/Cu_Records/Record[generate-id(.) = generate-id(key('a', ESN))]" mode="head">
</xsl:apply-templates>
</xsl:template>
<!-- IDoc-Struktur -->
<xsl:template match="Record" mode="head">
<xsl:param name="pTime"/>
<xsl:variable name="esn" select="ESN"/>
<YCSMKO01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<SNDPOR></SNDPOR>
<SNDPRT></SNDPRT>
<SNDPRN></SNDPRN>
<SNDLAD></SNDLAD>
</EDI_DC40>
<YCSMOTOR_KONF01 SEGMENT="1">
<KLU>TBD</KLU>
<TYP>TBD</TYP>
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>
<xsl:value-of select="concat(ESN,'#',substring-before(GRAPHIC_NAME, '.'))"/>
</YCSSTKLID>
</YCSMOTOR_KONF02>
<!-- Test Muenchian grouping -->
<xsl:for-each select="/ns:MT_FlatFile_Lists_Cu/Cu_Records/Record[generate-id(key('grouping, concat(./ESN, ./GRAPHIC_NAME)))]"/>
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>
<xsl:value-of select="concat(./ESN,'#',substring-before(./GRAPHIC_NAME, '.'))"/>
</YCSSTKLID>
</YCSMOTOR_KONF02>
<!-- End Muenchian -->
</YCSMOTOR_KONF01>
</IDOC>
</YCSMKO01>
</xsl:template>
</xsl:stylesheet>
Thank you very much in advance.
If I am guessing correctly, you want to do something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="urn:las:pp:ss1:tar"
exclude-result-prefixes="ns">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:key name="rec-by-esn" match="Record" use="ESN"/>
<xsl:key name="rec-by-grf" match="Record" use="concat(ESN, '|', GRAPHIC_NAME)"/>
<xsl:template match="/ns:MT_FlatFile_Lists_Cu">
<root>
<!-- group by ESN -->
<xsl:for-each select="Cu_Records/Record[generate-id() = generate-id(key('rec-by-esn', ESN))]">
<YCSMKO01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<SNDPOR></SNDPOR>
<SNDPRT></SNDPRT>
<SNDPRN></SNDPRN>
<SNDLAD></SNDLAD>
</EDI_DC40>
<!-- subgroup by ESN and GRAPHIC_NAME -->
<xsl:for-each select="key('rec-by-esn', ESN)[generate-id() = generate-id(key('rec-by-grf', concat(ESN, '|', GRAPHIC_NAME)))]">
<YCSMOTOR_KONF02 SEGMENT="1">
<YCSSTKLID>
<xsl:value-of select="concat(ESN,'#',substring-before(GRAPHIC_NAME, '.'))"/>
</YCSSTKLID>
</YCSMOTOR_KONF02>
</xsl:for-each>
</IDOC>
</YCSMKO01>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>
Note the way subgrouping is applied to the current group only, selected by the expression key('rec-by-esn', ESN).
I need to populate the line item E1EP01 in output structure only if the value of E1EP01/CODE = WK30 and E1EP01/E1EP19/TEXT is not blank , in input file.
I have written below line of codes but E1EP01 is not appearing in Output even if CODE has value equal to WK30 and TEXT is not blank
Can anyone please help me in this?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<ORDERS05>
<IDOC>
<xsl:if test=" ZXX/IDOC/E1EP01/CODE = 'WK30' and ZXX/IDOC/E1EP01/E1EP19/TEXT!= ' '">
<xsl:for-each select="E1EP01">
<E1EP01>
<POSEX>
<xsl:value-of select="ZXX/IDOC/E1EP01/POSEX"/>
</POSEX>
</E1EP01>
</xsl:for-each>
</xsl:if>
</IDOC>
</ORDERS05>
</xsl:template>
</xsl:stylesheet>
Sample input is shown below:
<?xml version="1.0" encoding="UTF-8"?>
<ZXX>
<IDOC BEGIN="1">
<E1EP01 SEGMENT="1">
<POSEX>00020</POSEX>
<CODE>WN14</WERKS>
<E1EP19 SEGMENT="1">
<Q>001</Q>
<TEXT>000000000000204034</TEXT>
</E1EP19>
</E1EP01>
<E1EP01 SEGMENT="1">
<POSEX>00010</POSEX>
<WERKS>WK30</WERKS>
<E1EP19 SEGMENT="1">
<Q>001</Q>
<TEXT>000000000000205115</TEXT>
</E1EP19>
</E1EP01>
</IDOC>
</ZXX>
Change:
<xsl:for-each select="E1EP01">
to:
<xsl:for-each select="ZXX/IDOC/E1EP01">
Note: you don't need to escape single quotes as ' in your test expression.
Added:
I need to test each E1EP01 for the condition and if condition matches
then that E1EP01 should appear in output.
Try it this way, then:
XSLT 1.0
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/ZXX">
<ORDERS05>
<IDOC>
<xsl:for-each select="IDOC/E1EP01[CODE='WK30' and E1EP19/TEXT!='']">
<xsl:copy>
<xsl:copy-of select="POSEX"/>
</xsl:copy>
</xsl:for-each>
</IDOC>
</ORDERS05>
</xsl:template>
</xsl:stylesheet>
I have an xsl stylesheet giving just about what is needed, except there are values outputted outside the tags, . Is there a way to remove them? The scenario is that the desired output is a total invoice amount for invoices that appear more than once. Each time the xslt is executed the parameter p1 contains the InvoiceNumber to total. The code below shows that parameter, p1, hardcoded to '351510'.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/Invoices/Invoice[InvoiceNumber=351510][1]/InvoiceNumber">
<xsl:copy>
<xsl:apply-templates select="/Invoices/Invoice[InvoiceNumber=351510][1]/InvoiceAmount"/>
</xsl:copy>
</xsl:template>
<xsl:param name="tempvar"/>
<xsl:template name="InvTotal" match="/Invoices/Invoice[InvoiceNumber=351510][1]/InvoiceNumber">
<xsl:variable name="p1" select="351510" />
<xsl:if test="/Invoices/Invoice/InvoiceNumber[. = $p1]">
<!--<xsl:if test="$test = $p1" >-->
<InvoiceAmount>
<xsl:value-of select="sum(../../Invoice[InvoiceNumber=351510]/InvoiceAmount)"/>
</InvoiceAmount>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Here is the input:
<Invoices>
- <Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>137.00</InvoiceAmount>
</Invoice>
- <Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>363.00</InvoiceAmount>
</Invoice>
- <Invoice>
<InvoiceNumber>351511</InvoiceNumber>
<InvoiceAmount>239.50</InvoiceAmount>
</Invoice>
</Invoices>
Here is the output:
<InvoiceAmount>500</InvoiceAmount>137.00351510363.00351511239.50
Here is desired output:
<InvoiceAmount>500</InvoiceAmount>
Also, thank you goes to lwburk who got me this far.
Adding
<xsl:template match="text()"/>
should help.
I do not get the same results as you posted (only 351510137.00351510363.00351511239.50, all the text nodes), and I do not know the purpose of tempvar (unused).
Since it appears that all you need is the sum of InvoiceAmount values for a specific InvoiceNumber, just keep it simple and ignore everything else:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:param name="invoiceNumber"/>
<xsl:template match="/">
<InvoiceAmount>
<xsl:value-of select="sum(/Invoices/Invoice[InvoiceNumber=$invoiceNumber]/InvoiceAmount)"/>
</InvoiceAmount>
</xsl:template>
</xsl:stylesheet>
You can pass the InvoiceNumber to process via the parameter invoiceNumber, or you can hardcode it if you like (see version 1).
Note: should you prefer a number format like e.g. #.00 (fixed decimals) for the sum, then you can also use the format-number(…) function.
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pNum" select="351510"/>
<xsl:key name="kInvAmmtByNumber" match="InvoiceAmount"
use="../InvoiceNumber"/>
<xsl:variable name="vInvoiceAmounts" select=
"key('kInvAmmtByNumber', $pNum)"/>
<xsl:variable name="vIdInvAmount1" select=
"generate-id($vInvoiceAmounts[1])"/>
<xsl:template match="InvoiceAmount">
<xsl:if test="generate-id() = $vIdInvAmount1">
<InvoiceAmount>
<xsl:value-of select="sum($vInvoiceAmounts)"/>
</InvoiceAmount>
</xsl:if>
</xsl:template>
<xsl:template match="text()"/>
</xsl:stylesheet>
when applied on the provided XML file:
<Invoices>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>137.50</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351510</InvoiceNumber>
<InvoiceAmount>362.50</InvoiceAmount>
</Invoice>
<Invoice>
<InvoiceNumber>351511</InvoiceNumber>
<InvoiceAmount>239.50</InvoiceAmount>
</Invoice>
</Invoices>
produces exactly the wanted, correct result:
<InvoiceAmount>500</InvoiceAmount>
Explanation:
The wanted invoice number is passed to the transformation as the value of the external/global parameter $pNum .
We use a key that indexes all InvoiceAmount elements by their corresponding InvoiceNumber values.
Using that key we define the variable $vInvoiceAmounts that contains the node-set of all InvoiceAmount elements the value of whose corresponding InvoiceNumber element is the same as the value of the external parameter $pNum.
We also define a variable ($vIdInvAmount1) that contains a unique Id of the first such InvoiceAmount element.
There is a template that matches any InvoiceAmount element. It checks if the matched element is the first of the elements contained in the node-set $vInvoiceAmounts. If so, a InvoiceAmount element is generated with a single text-node child, whose value is the sum of all InvoiceAmount elements contained in $vInvoiceAmounts. Otherwise nothing is done.
Finally, there is a second template that matches any text node and does nothing (deletes it in the output), effectively overriding the unwanted side effect of the default XSLT processing -- the outputting of unwanted text.
I am creating an XSLT and i want to select a particular node, only if one of its child element's value is between a range. The range is to be specified using parameters in the xsl file.
The XML file is like
<root>
<org>
<name>foo</name>
<chief>100</chief>
</org>
<org parent="foo">
<name>foo2</name>
<chief>106</chief>
</org>
</root>
The XSLT so far is
<xsl:param name="fromRange">99</xsl:param>
<xsl:param name="toRange">105</xsl:param>
<xsl:template match="/">
<xsl:element name="orgo">
<xsl:apply-templates select="//org[not(#parent)]"/>
</xsl:element>
</xsl:template>
I want to restrict the org node from being processed whose < chief > node's value is not in range
I want to select a particular node,
only if one of its child element's
value is between a range. The range is
to be specified using parameters in
the xsl file.
I also want the restriction that the
node should not have a parent
attribute along with the range
Use this expression as the value of the select attribute of <xsl:apply-templates>:
org[not(#parent) and chief >= $fromRange and not(chief > $toRange)]
In XSLT 2.0 it is legal to have variables/parameters in the match pattern.
Therefore, one could write:
<xsl:template match=
"org[#parent or not(chief >= $fromRange ) or chief > $toRange]"/>
thus effectively excluding all such org elements from processing.
Then the template matching the document node is simply:
<xsl:template match="/">
<orgo>
<xsl:apply-templates/>
</orgo>
</xsl:template>
This is better than the XSLT 1.0 solution, because it is more "push-style".
//org[chief < $fromRange and not(#parent)]
|//org[chief > $toRange and not(#parent)]
This expression will exclude all nodes that are in the range specified by fromRange and toRange.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="fromRange">99</xsl:param>
<xsl:param name="toRange">105</xsl:param>
<xsl:template match="/">
<xsl:element name="orgo">
<xsl:apply-templates select="//org[chief < $fromRange and not(#parent)]|//org[chief > $toRange and not(#parent)]"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>