It's not a secret anymore!*
The moose likes XML and Related Technologies and the fly likes An Unwanted Part of the XML Input File is Included in the XSL Transformation Result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "An Unwanted Part of the XML Input File is Included in the XSL Transformation Result" Watch "An Unwanted Part of the XML Input File is Included in the XSL Transformation Result" New topic
Author

An Unwanted Part of the XML Input File is Included in the XSL Transformation Result

Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
I am transforming a XML file to another XML file using XSL. The XSL did the intended transformation except a part of the XML input file is not supposed to appear in the XML output file.

I think it is a problem in my XSL file. But, I do not know how to suppress something from showing up in the output file. I appreciate your help.

Below is my XML input file. I need the information inside the <pathParametersExt> node to do the XSL transformation; however, I do not want the information inside the <pathParametersExt> node to be included in the output file.



Here is my XSL transformation (the CommonFunctions.xsl only has some date time and encoding utilities):


The <pathParametersExt> node and its child nodes in the XML output file is redundant. Here is the unexpected output file:





Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, the main processing part of your XSLT code is from lines 72 to 82 in your post. And what you have there is the standard identity transformation, which recursively copies each node from the input to the output. (The only difference is line 75, which looks like it throws an exception if the setup was incomplete.) And you have overridden that identity transformation so that when it gets to the h:queryParametersExt element, it does something other than just copying the element. That starts at line 92.

But you don't have any code to say what to do with the h:pathParametersExt element, so by default it is copied to the output. And that isn't what you want. So you need to add another template (like the one starting at line 92) which says "When you get to the h:pathParametersExt element, don't do anything".
Natalie Kopple
Ranch Hand

Joined: May 06, 2003
Posts: 325
Thanks for your help and explanation. It is working now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: An Unwanted Part of the XML Input File is Included in the XSL Transformation Result