I have an input xml as below
<maindocument>
<first>
<testing>random text</testing>
<checking>random test</checking>
</first>
<testing>
<testing>sample</testing>
<checking>welcome</checking>
<import>
<downloading>valuable text</downloading>
</import>
</testing>
</maindocument>
The output here i want the same output like below
<maindocument>
<import>
<doctype>Valuable</doctype>
<docint>text</docint>
</import>
</maindocument
I am trying for the above code in xslt With the help of absolute path and relative path my question is how i will get into testing element then i have to select import element from there.
Please guide me
Regards
Karthic
Actually, there is no need to specify a complete path to
testingand check that it has animportchild.The XSLT processing model (built-in templates), combined with your templates and proper template match patterns, does the navigation for you.
The built-in templates are selected for execution if there is no explicit template that matches a particular node. he cumulative result of applying the built-in templates is that the document tree is traversed and only text nodes are output.
One can specify templates to override the built-in ones only for nodes that should be processed in a different, specific way. When the built-in templates apply templates for a child of a node and there is explicit (user-provided) template matching that node, this explicit template is selected for execution/processing of that node.
This short XSLT 1.0 transformation:
when applied on the provided XMLdocument:
produces the wanted, correct result: