Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 March 8th, 2007, 07:13 AM
Authorized User
 
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default String in XSLT

i am writing a function in a Class and then binds all the data to a string and then send it to the XSLT
public string GetAllData
{
 for(int i=0;i<xmlnode.Count;i++)
 {
 XmlAttributeCollection xmlattrc = xmlnode[i].Attributes;

 all += "<br>";
 all += xmlattrc[0].Name;
 all += xmlattrc[0].Value;

 all += "<br>";
 all += xmlnode[i].FirstChild.Name;
 all += xmlnode[i].FirstChild.InnerText;


 all += xmlnode[i].LastChild.Name;
 all += xmlnode[i].LastChild.InnerText;

 }
 return all;
}

and then using it in XSLT like this

<xsl:value-of select="RDisc:GetAllData()" />

but is showing data in one line also included the <br> how i can solve this. I have also tried as

all +=&lt;br&gt;

but it is not working how can i resolve this issue.



I Love XML and family
__________________
I Love XML and family
 
Old March 8th, 2007, 08:53 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't know why you're calling an extension function to do something that can be done very easily in XSLT. Extension functions are implementation-defined, but I would expect most implementations to require them to return XPath values - strings or nodes - not a chunk of serialized XML (or HTML). Remember that XSLT is about transforming trees, not lexical XML.

Rewrite your code in XSLT, it will be much cleaner.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 8th, 2007, 09:07 AM
Authorized User
 
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i got ur point,if i am not wronh u r sauing that i should access the XML directly into XSLT [sorry, if i am wrong] but problem is i am fetching some data from SQL and filling it to the DataSet and then passing that DataSet to the XML DataDocument object. like this.

adap.Fill(dsOrders,"Table1");
XmlDataDocument XMLDoc = new XmlDataDocument(dsOrders);

and then again some result to same dataset

and when i to merge some 2nd XML document suppose student2.xml inside XSLT it does not produce any result and does not even sho any error. so i used this as alternative.

anywaz is there still any solution for this problem. i mean how to include <br> in string.

i want output in this format.

type: Single, units: 2
type: Double, units: 3
type: Triple, units: 4


but i am getting <br>type: Single, units: 2<br>type: Double, units: 3 ....etc

any tip


I Love XML and family
 
Old March 8th, 2007, 09:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>if i am not wronh u r sauing that

Please do me the courtesy of writing English sentences.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 8th, 2007, 09:51 AM
Authorized User
 
Join Date: Mar 2007
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

> Please do me the courtesy of writing English sentences.

is it from XPath or from XSL-FO

come on i need answer, i don't want you to correct my English.



I Love XML and family





Similar Threads
Thread Thread Starter Forum Replies Last Post
string to binary conversion in XSLT navi25584 XSLT 5 September 3rd, 2008 03:14 AM
Parse XML string parameter from XSLT maulik33 XSLT 6 December 5th, 2007 11:51 AM
Can XSLT read DTD/schema and Generate XSLT.. ROCXY XSLT 1 November 6th, 2006 09:39 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
XSLT String Tokenizing townsfolk All Other Wrox Books 2 March 26th, 2004 05:05 AM





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