XML to XML with condition

wxdqz

New Member
I need an xslt document that can tranform the following xml into the second

A) input

<TOPOBJECT>
<NODEA ID='781'>A</NODEA>
<nodeb ID='785'>B</nodeb>
<nodec ID='782'>C</nodec>
<bignodes ID='89' inDX='100' outDX='55' dir='left'>
<ccua ID='12'>cc 1</ccua>
<dcc ID='67' x='zone'>bA1</dcc>
<dcc ID='68' x='zone'>bA2</dcc>
<dcc ID='680' x='zone'>bA3</dcc>
</bignodes>
<bignodes ID='893' inDX='100' outDX='52' dir='left'>
<ccua ID='123'>super cc</ccua>
<dcc ID='673' x='zone' value='http://www.webdeveloper.com/forum/archive/index.php/5'>bB1</dcc>
<dcc ID='683' x='zone'>bB2</dcc>
<dcc ID='6803' x='zone' value='http://www.webdeveloper.com/forum/archive/index.php/-99'>bB3</dcc>
</bignodes>
<bignodes ID='894' inDX='101' outDX='90' dir='left'>
<ccua ID='124'>bA</ccua>
<dcc ID='674' x='zone'>bC1</dcc>
<dcc ID='684' x='zone'>bC2</dcc>
<dcc ID='6804' x='zone'>bC3</dcc>
</bignodes>
</TOPOBJECT>

B) output

<TOPOBJECT>
<NODEA ID='781'>A</NODEA>
<nodeb ID='785'>B</nodeb>
<nodec ID='782'>C</nodec>
<bignodes ID='89' inDX='100' outDX='2000' dir='left'>
<ccua ID='12'>super cc</ccua>
<dcc ID='67' x='zone' value='http://www.webdeveloper.com/forum/archive/index.php/20'>bA1</dcc>
<dcc ID='68' x='zone'>bA2</dcc>
<dcc ID='680' x='zone'>bA3</dcc>
</bignodes>
<bignodes ID='894' inDX='101' outDX='90' dir='left'>
<ccua ID='124'>bA</ccua>
<dcc ID='674' x='zone'>bC1</dcc>
<dcc ID='684' x='zone'>bC2</dcc>
<dcc ID='6804' x='zone'>bC3</dcc>
</bignodes>
</TOPOBJECT>


English instructions would be

deep copy the entire structure however:
if there is a bignodes whose ccua field contains the string 'cc' do the following
1) if ccua = "cc 1" discard that node
2) else
2a) change bignodes attribute outDX to 2000
2b) for every dcc node whose attribute "value">0 set value=http://www.webdeveloper.com/forum/archive/index.php/20
2c) eliminate any dcc node whose attribute "value" < 0


If at all possible I would prefer the script to know the least amount possible about the actual structure of

point 2b & 2c are the least important.
Can anyone help me? Please
<!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->
 
Back
Top