How to transform XML by using XSLT

Hi
I need to know how to transform a XML file by using a XSLT file. Consider the following XML file

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><LogFile><Dog TimeStamp="16.02.2004 10:04:48" ModifiedBy="Smith, Geoff"><NameOfDog>Fido</NameOfDog><Weight>10</Weight></Dog><Dog TimeStamp="16.02.2004 10:05:24" ModifiedBy="Scott, Al"><Color>Black</Color><Weight>12</Weight></Dog></LogFile

By the magic of some XSLT file I want the following output to be created.

Modified by: Smith, Geoff (16.02.2004 10:04:48
	Name of the Dog: Fid
	Weight: 1

Modified by: Scott, Al (16.02.2004 10:05:24
	Color: Blac
	Weight: 1

Does anybody know how this can be done? How can I output ALL elements of one node without having to name all children using <xsl:value-of select="NameOfElement" />, ..
Thank you a great lot!!

   Daniel Walzenbach
0
2/16/2004 1:46:08 PM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
626 Views

Similar Articles

[PageSpeed] 8

"Daniel Walzenbach" <daniel.walzenbach.NOSPAM@freudenberg.de> wrote in message
news:5C9D0D65-5D3C-4CD0-9964-DB3B12892C57@microsoft.com...
> I need to know how to transform a XML file by using a XSLT file. Consider the following XML file:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?><LogFile>
> <Dog TimeStamp="16.02.2004 10:04:48" ModifiedBy="Smith,
> Geoff"><NameOfDog>Fido</NameOfDog><Weight>10</Weight>
> </Dog>
: :
> Modified by: Smith, Geoff (16.02.2004 10:04:48)

Daniel,

You'll have to set the xsl:output element to set an output method of text,
and then it's simply a matter of placing the results of several XPath
expressions at the desired places in a document.

For starters,

- - - DogLog.xsl (excerpt)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" />

    <xsl:template match="LogFile/Dog">
        <xsl:text>Modified by: </xsl:text>
        <xsl:value-of select="@ModifiedBy" />
        <xsl:text> (</xsl:text>
        <xsl:value-of select="@TimeStamp" />
        <xsl:text>)&#x0d;&#x0a;</xsl:text>
    </xsl:template>

    <xsl:template match="/">
        <xsl:apply-templates select="LogFile/Dog" />
    </xsl:template>

</xsl:stylesheet>
- - -

With text output, settings for whitespace preservation may conflict with
natural and clear indenting of XSL source, so rather than just use a basic
literal text document with preserved whitespace, I use xsl:text elements
above to precisely distinguish the literal text content I want emitted into
the target document from the other whitespace that is only used to
present a readable stylesheet.

In these text elements, you see the two character entities, #x0d; and #x0a;
which correspond to the carriage return and line feed (ie, the character
codes you may be more familiar with from C languages as "\r\n") that intro-
duce a newline into the text output.

There are two template rules in this stylesheet.  The first matches the root
node of the document (which in XPath-thinking, is the node containing the
document element, LogFile) and applies the second template (iteratively)
over each record wrapped by the Dog element.

The xsl:value-of elements are how the result of XPath expressions against
the source document get injected into the result document.  From this basic
skeleton, you should be able to extend it further to create text reports
formatted however you like.


Derek Harmon


0
loresayer (274)
2/16/2004 3:36:45 PM
Thank you Derek. I have to look for some kind of tutorial for this kind of stuff.

Best regard

   Daniel
0
2/17/2004 9:46:05 AM
Reply:

Similar Artilces:

using CListCtrl::Sort() with OWNER DATA
This is a multi-part message in MIME format. ------=_NextPart_000_000A_01C3DC71.9497D720 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey All, 1. Which sorting method does CListCtrl::Sort() use? eg Quick, merge, = bubble, insertion, selection. And is it a stable sort? eg the sorted = data sequence preserves the original (input) relative ordering of = equivalent data units. 2. Is it possible to use the very SAME CListCtrl::Sort() method with the = OWNER DATA option for my own data? I understand that I cannot simply = call CListCtrl::S...

xml schema to dataset to xml
Hi, I am trying to write a function that takes an xml schema and generates a dataset. I then write data into the dataset and generate xml from it. I then go to validate the xml that was generated against the original schema and the validation fails. Ive found that this is because the order of the sequence in my complex types is no longer the same. Does anyone know of a way to generate xml that will validate against the schema? ...

Pivot table using External data
Hi I am generating a pivot table using the following query SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100 REG$'` `'1100 REG$'` UNION SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157 REG$'` `'1157 REG$'` UNION SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165 REG$'` ...

using the Lotus 1-2-3 file import, numbers command in excel
how do i use the lotus 1-2-3 file import, number command in an excel spreadsheet? this command in lotus..allows me to just import numbers, no text is imported..i do not want to import text...please advise..im trying to convert a lotus spreadsheet to excel and i need to figure out how to do this in excel ...

HELP? Having some problems with XML Serialization...
Hi, I seem to be having a bit of a problem serializing a complex object into XML. I've done this many times with simpler objects and it's always worked just fine. The error I'm getting is the natorious "File or assembly name [asciijunk].dll, or one of its dependencies was not found. I have turned on XML Serialization debugging int the web.config file, so I have all of the output generated by the serializer. When I examine the .out file generated there, I have the following: ================================================== c:\Documents and Settings\DEV100\ASPNET\L...

transform data in excel
I need to transform data in an excel srpeadsheet. I need to reverse a 5 rows, 200 columns table into a 5 columns, 200 rows table. Much appreciated!Vincent Hi Vincent Copy the set of data. Got to your destination and choose Paste Special and click the box marked Transpose. -- Regards Roger Govier "Vincent Yang" <vyang69@verizon.net> wrote in message news:MVORb.1866$px6.279@nwrddc02.gnilink.net... > I need to transform data in an excel srpeadsheet. I need to reverse a > 5 rows, 200 columns table into a 5 columns, 200 rows table. > > Much appreciated!Vincent >...

Remove Dataset name as ROOT of XML
Hi, I am generating deeply nested XML document from a Dataset using ' Write to the file with the WriteXml method. DataSet21.WriteXml(myXmlWriter) The generated XML contains the <DataSet2> node as a root node (see below) is there a way to get rid of it? I ned the <Header> node to be a Root node. All info is generated from database. Thanks LoF <DataSet2> <Header> <WONo>2308100</WONo> <EDDID>SEDD</EDDID> .... create an XmlDataDocument from the DataSet http://msdn.microsoft.com/library/en-us/cpref/html/frl...

Simple Xml Validation with strings
Hello, I have two strings; string XmlFragment; //contains the xml document string XsdSchema; //contains the xsd schema I would like to validate the XmlFragment against the XsdSchema. What is a clean, simple way for accomplishing this? Bye, Ward Try something like this: 1) Load your XsdSchema into a StreamReader MemoryStream ms = new MemoryStream((new Text.ASCIIEncoding()).GetBytes(XsdSchema)); StreamReader schemaReader = new StreamReader(ms); 2) Validate your XmlFragment on the StreamReader XmlTextReader xmlReader = new XmlTextReader(new System.IO.StringReader(XmlFragment)); X...

Comparing a value in EXCEL and XML files
want to know how to write a code in VB.NET for the following situation > I have a field( Ex. Capital) in my XML file and that field results in a value(Ex. $5000)....now i have my Excel file with multiple worksheets in it....I want to write a code that can read a single field (Ex. Capital) in XML file and then take it's value (Ex.$5000).....After reading the $5000 it should search through my entire Excel file( In all Worksheets) and see if that Value exists ....If it exists then return as "Pass" if not "Fail".....I also hav 1 more condition but first i would like to...

How to XslTransform.Transform to new web page from code behind?
I'm working with a typed dataset and want to implement a print button that prints my formatted data without the company logo and other stuff on the form. I've created an XSLT file to transform the XML version of the dataset into HTML and would like to display it in a new browser window leaving the original window up and/or maybe even just send it out to the default printer or bring up the print dialog for printing out the web page. I have successfully saved the html file, but I'm not sure how to send to a new browser window instead of a file. Please help, code below: XmlData...

Use Regex to remove Attributes
Hello, I have a string as follows: <span class="A" id="A"><span class="B" id="B">Some Text</span></ span> Basically I want to remove all the attributes from span B: <span class="A" id="A"><span>Some Text</span></span> So maybe the easiest way would be to get all the text inside the inner span and then recreate everything inside: <span class="A" id="A">...</span> How can I do this? I think the best option would be Regex. Or not?...

XSL Transform Problem using Xml.XSL.Transform
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to transform from my watch window into a file.. It works perfectly. Any Ideas? The following is the C# code I am using to transform & the XSL I a...

XIRR Function Using Months Instead of Years
I am trying to modify a model that uses the XIRR function. Instead of breaking revenue and costs down by year, I want to do it by month. The result of the XIRR function when I do that, though, is overstated quite a bit. Any ideas what I am doing wrong? Thanks! Do you have a list of dates for you cash flow? And are they dates? From help: "Dates should be entered by using the DATE function, or as results of other formulas or functions. For example, use DATE(2008,5,23) for the 23rd day of May, 2008. Problems can occur if dates are entered as text." HTH, Bernie MS Excel MVP ...

Using a COM dll in VC++
I a work colleague wrote a dll in VB with COM stuff. I need to use this dll in VC++. How do you do that? My knowledge of dll especially COM dll is fairly limited. See if the following article offers you any help. Calling a VB ActiveX DLL from a MFC Client http://www.codeproject.com/dll/vbactivexwithvc.asp -- Cheers Check Abdoul [VC++ MVP] ----------------------------------- "nerram" <kevin.marren@hp.com> wrote in message news:ab54811.0311190052.7d425db@posting.google.com... > I a work colleague wrote a dll in VB with COM stuff. I need to use > this dl...

Intermittent fault when using outlook web access
This fault is intermittent and occures when we try and access our e-mails across the internet using the outlook web access. Most of the time there is no problem, then another time we cannot gain access to the exchange server. The most recent happened today. Everything was fine yesterday, we restarted the server where we tried dialing in from this morning and now we cannot access E-mail. All the exchange services are running on both servers. Any ideas? Try posting to an Exchange group as Outlook Web Access is a function of Exchange, not Outlook. microsoft.public.exchange.admin i...

Change file name from folder using VBA
Hi All - Please, can anyone help to write a coding for changing the filenames (all format) from a folder. i.e, I am having 2 files in C:\ C:\test.xls C:\test1.pdf Can we change these file names using VBA (Excel) as - C:\changed.xls C:\changed1.pdf Thanks a lot in advance. Ratheesh I did a search for "vba rename file" and got several promising hits. --JP On Nov 18, 10:17=A0am, Ratheesh <ratheesh.ramachandh...@gmail.com> wrote: > Hi All - > > Please, can anyone help to write a coding for changing the filenames > (all format) from a fo...

reduce decimal places of number used in formula
I use Excel 2000. I pulled a number with 5 decimal places into a contract, reducing it to 3 decimal places. I then use that number in a formula to figure a cost to be billed. I only want to use the 3 decimal number in the formula. Is there a way for the formula to use the 3 decimals only without having to actually re-type the number. I use this sheet monthly and would like it to do it automatically. Catz, If your number is in cell A1, when you reference it, use ROUND(A1,3) So, instead of =A1*100 use =ROUND(A1,3)*100 HTH, Bernie MS Excel MVP "CatzJ" <CatzJ@di...

XML parsee
Hi All I am very new to XML ... i have an xml file how do i parse it.. Its has a very simple structure : I need to get the output in the following for/m: For all records: Get the fieldname, Then check the Filetype if input then ignore if derived then retrieve the file name if constant then get the constant value. please help me out i need to parse this asap Expectin a quick reply.. i need a optimized one as this records in the xml will be hugs.. Thanks a lot Regards Hemlata Fields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Cour...

Transform table into calendar format
I have a table with dates (column A) and events (column B). I wanted to know how I automatically create a calendar template with the events I have on this separate sheet. Send me an email to: pashurst <at> auditel.net (change the obvious), and I'll send you a file that does just what you describe. Hope this helps. Pete On Nov 18, 9:55=A0pm, Matheus <Math...@discussions.microsoft.com> wrote: > I have a table with dates (column A) and events (column B). I wanted to k= now > how I automatically create a calendar template with the events I have on = ...

How do I use multiple input ranges with PivotTables
Trying to report on two simple ranges from different worksheets, is this possible? hi, yes it is. if you want more info....supply more detail. >-----Original Message----- >Trying to report on two simple ranges from different worksheets, is this >possible? >. > ...

Want to alphabetize address labels using something other than Mer
Have a large address file on mailing labels . Have tried using Merge to alphabetize the list, but find this rather cumbersome. Would like to find a simple quick way to do it. Any suggestions? Maybe I'm missing something here, but can't you just select all of the columns then use Data/Sort... and choose the column that you want to use to sort by? I have a column in my address list for Last Name and that is what I use to alphabetize the list. Merry Christmas "WindyHill" <WindyHill@discussions.microsoft.com> wrote in message news:93D99BFF-46EE-484A-93A0-750EB34CF...

Encrypt Information When Using the Network
In Tools, Services, Properties of Exchange Server, Advanced Tab, there is a section called Encrypt Information. There is a check box within that section which states "when using the network". When that box is checked, what does that mean? Does that mean Outlook requests the RPC session to the server be encrypted? Are there any technical articles describing this encryption? I've been searching constantly and all I can find is info on KM server and certificates and signing messages. I'm just trying to find out if information sent between and Outlook client and an Exchange...

how to use CryptoGraphy.
hi all, i have used cryptography using RC2 and RC4 Algorithms. but how it is used in Real Time projects. How to Congigure the Digital Certificates and how to Use Tripple Des Algorithm. Please give me your suggestions and steps to be followed. thanks, uday. "uday" <uday@discussions.microsoft.com> wrote in message news:67432F69-D5A3-408D-A207-144173EA7197@microsoft.com... | hi all, | | i have used cryptography using RC2 and RC4 Algorithms. but how it is used in | Real Time projects. How to Congigure the Digital Certificates and how to Use | Tripple Des Algorithm. Please ...

create email newsletter with pictures and hyperlinks using publis
I want to create an email newsletter in publisher that will contain pictures and hyperlinks. Basically, I can do this right in my yahoo email but I can't get the fancy formats like those in publisher. What type of file should I save it as and then how do link it to the email. I've tried doing this several ways including saving it as a webpage or jpg file, publishing the page, and then copying it to the email text --- but that didn't work. What am I doing wrong here? "John Downing" <JohnDowning@discussions.microsoft.com> wrote in message news:49470DF6-A4...

Seven Transformation
My son in his infinite wisdom downloaded something called Windows 7 transformation to my XP computer. Now I can't remove it. When I run "remove Seven Transformation Pack" it instantly gives me an error. This happens whether I run it from Control Panel or otherwise. Help! How can I get rid of this? Jpstewar wrote: > My son in his infinite wisdom downloaded something called Windows 7 > transformation to my XP computer. Now I can't remove it. When I run > "remove Seven Transformation Pack" it instantly gives me an error. > This happens whether...