aspose file tools*
The moose likes XML and Related Technologies and the fly likes Embedding XML tags in XSL 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 "Embedding XML tags in XSL" Watch "Embedding XML tags in XSL" New topic
Author

Embedding XML tags in XSL

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hello All,
What I am trying to do is that I have an XML document and I want to apply a XSL stylesheet to produce another XML document.
I have right xsl utput method="xml". Still my new xml tags which I have embedded in the XSL would not show up. I am using IE 6.0. Also I am using apply-templates select=..... and so forth. I do not understand why my xml would not show up.

Thank you very much in advance for your help!
-Amish
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Need some help!
Thanks
Amish
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
It should work. Maybe you could post your XML and XSL files (if they are not too long ) here for better diagnostics.
Sumeet Pandit
Greenhorn

Joined: Mar 09, 2002
Posts: 10
Dear Amish,
Post ur code to check it properly...Definately there will be some solution.


- Sumeet<br />-----------------------------------
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
The following is the xml file AddLineItemReturn.xml

The following is my stylesheet Add_Line_Item_ii.xsl, as you will see when you apply the stylesheet to the above xml file, the TransactionReturn tags are missing, but if I insert an xml text and then TransactionReturn it works perfectly fine.


Thanks in advance for youe help!!!
Mapraputa Is
Leverager of our synergies
Sheriff

Joined: Aug 26, 2000
Posts: 10065
<TransactionReturn> thing works perfectly for me, so do <InsertItem> and other. The only problem in your stylesheet is how you generate Date element. XSLT has to be a well-formed XML and <xsl:text><Date </xsl:text> is surely not well-formed. There are XSL elements that you can use to add XML elements to output: <xsl:element> and <xsl:attribute> In your case it will be
<xsl:element name="Date">
<xsl:attribute name="Day">
<xsl:value-of select="Day"/>
</xsl:attribute>

</xsl:element>

And there is shorter version:
<Date Day="{Day}" Month="{Month}" Year="{Year}"/>
The whole stylesheet would be:

It works with Xalan transformer. Now all the problems with IE browser belongs to IE! Generally it's not a good idea to use a browser for XSLT transformation, because there are some compatibility issues. You can read this post for more information.
[ April 02, 2002: Message edited by: Mapraputa Is ]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks Mapraputa You have been a great help.
This works like a charm. I was using MS IE to validate my XML and apply XSL. Also an interesting thing I found out is MS IE 6.0 also does not adhere to XML/XSL Specification. I always thought and Microsoft claims that IE 6.0 will adhere to the specs. But I guess not.
Once again thank you very much for your help!
-Amish
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Embedding XML tags in XSL