Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
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
 
Old November 9th, 2006, 11:55 AM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

 
Old November 9th, 2006, 12:51 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old November 9th, 2006, 01:43 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old November 9th, 2006, 02:33 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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


 
Old November 9th, 2006, 02:38 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)
 
Old November 9th, 2006, 02:42 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old November 9th, 2006, 02:48 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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!

 
Old November 9th, 2006, 02:54 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old November 9th, 2006, 02:59 PM
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you suggest some tool or some way to execute xslt?

Thanx!!


 
Old November 9th, 2006, 03:02 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

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)




Similar Threads
Thread Thread Starter Forum Replies Last Post
strip html tags with xslt smiter XSLT 4 June 19th, 2012 08:34 AM
xslt for tags dnandhak XSLT 4 May 23rd, 2008 05:57 AM
add HTML tags via XSLT chopswil2 XSLT 3 November 5th, 2007 09:30 AM
Replacing tags within xml using xslt patelgaurav85 XSLT 0 June 19th, 2007 12:34 PM
adding tags to output amitda XSLT 4 June 1st, 2007 11:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.