 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 9th, 2006, 11:55 AM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
XSLT output with tags
I was wondering is it possible to get output in xml format....this output should contain tags along with "<"
I tried using <xsl:output method="xml" indent="yes"/> but it does not dispaly the tags. I am able to get the tag names somehow but I want the output to be in proper xml format.
|
|

November 9th, 2006, 12:51 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
I'm sorry but I've no idea what you're on about.
Please read the first post in this forum about providing examples of what you have and what you want.
--
Joe ( Microsoft MVP - XML)
|
|

November 9th, 2006, 01:43 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
The output will normally be in XML format. I can't tell what you're doing wrong because you haven't said enough about what you are doing. Please show a simple stylesheet, the output you want and the output you are getting.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

November 9th, 2006, 02:33 PM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for rsponding and trying to help.
My xslt code is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="Package/Asset">
<xsl:element name="identifier">
<xsl:value-of select="@Asset_Id"/>
</xsl:element>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The output I m getting is
3180392 3180393 3180394 3180395 3180396 3182837 3182838 3190026 9561679 9524623 10117642
(This is just a listing of Ids)
Output I want is
<Identifier>3180392 </identifier>
<Identifier>3180393 </identifier>
....
I dont want to extract the tag names from my xml file as I am modifying those in the xslt file. So I want to explicitely specify the tag names in my xslt file so that the modified tag names appear with appropriate data in XML format.
Thanks once again
|
|

November 9th, 2006, 02:38 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Just looks to me that your browser hasn't recognised the file as XML, maybe because there's no document element. IE tends to cache the file type so also try renaming the output file.
--
Joe ( Microsoft MVP - XML)
|
|

November 9th, 2006, 02:42 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Your code looks fine as far as I can tell. Possibilities are:
(a) you aren't actually running this stylesheet against this source document. (Only a suggestion, we've all done this at one time or another)
(b) you're displaying the output of the transformation in such a way that the tags don't get shown (in an HTML browser, perhaps?)
So I think the questions are, how are you running the transformation, and how are you displaying the results?
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

November 9th, 2006, 02:48 PM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have this line of code in my xml file (asset.xml) that calles the xslt file
<?xml-stylesheet type="text/xsl" href="package_asset.xsl"?>
I get the output
3180392 3180393 3180394 3180395 3180396 3182837 3182838 3190026 9561679 9524623 10117642
when I open my xml file(asset.xml) in IE.
I even tried renaming this xml file but I get the same output.
Thanks!! Really appreciate your help!
|
|

November 9th, 2006, 02:54 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
OK thanks, I came to the conclusion you must be running in the browser, it seemed the only explanation. I simply don't know enough about IE to know whether this is possible. Your XSLT is fine, it's an IE problem.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|
|

November 9th, 2006, 02:59 PM
|
|
Authorized User
|
|
Join Date: Nov 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can you suggest some tool or some way to execute xslt?
Thanx!!
|
|

November 9th, 2006, 03:02 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
|
|
Did you try adding a document element?
Code:
<xsl:template match="/">
<identifiers>
<xsl:for-each select="Package/Asset">
<identifier>
<xsl:value-of select="@Asset_Id"/>
</identifier>
</xsl:for-each>
</identifiers>
</xsl:template>
I also simplified the XSLT, you only usually use the xsl:element element when you need to specify the name dynamically.
--
Joe ( Microsoft MVP - XML)
|
|
 |