Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML to XML (newbie question)?

Status
Not open for further replies.

jerryleb

Technical User
Nov 24, 2009
3
0
0
CA
Hi,

I figured really small examples work better than big complicated ones for us just starting out. Trying to learn how to "transform?" the first XML document (Example 1 - baseball.xml) so that it ends us as an XML file that looks like this coding below. I have several tables in MS Access that pretty well follow the same structure below....just need to see how this small example works (or links that explain how this works for us new persons to XML).

Hope this makes sense.....obviously I have a long ways to go to understand XML and XSL.

Jerry

END RESULT - baseballtransformed.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata" generated="2009-11-20T08:22:04">
<baseball>
<player>
<1 name="George" team="Detroit" other=""/>
<2 name="Roger" team="Chicago" other=""/>
<3 name="Will" team="Chicago" other="Out Sick"/>
<4 name="Joe" team="Detroit" other="Left Handed"/>
</player>
</baseball>
</dataroot>

NOTE: When I click on my Example 1 baseball.xml file, I see the following in my webbrowser:
< 1 name="George" team="1" other="" /> < 2 name="Roger" team="2" other="" />< 3 name="Will" team="2" other="Out Sick" />< 4 name="Joe" team="1" other="Left Handed" />



----------------------------------------------------
EXAMPLE 1 - baseball.xml
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="baseball.xsl"?>
<dataroot xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata" generated="2009-11-20T08:22:04">
<baseball>
<player>
<id>1</id>
<name>George</name>
<team>1</team>
<other />
</player>
<player>
<id>2</id>
<name>Roger</name>
<team>2</team>
<other />
</player>
<player>
<id>3</id>
<name>Will</name>
<team>2</team>
<other>Out Sick</other>
</player>
<player>
<id>4</id>
<name>Joe</name>
<team>1</team>
<other>Left Handed</other>
</player>

<team>
<id>1</id>
<name>Detroit</name>
</team>
<team>
<id>2</id>
<name>Chicago</name>
</team>
</baseball>
</dataroot>

EXAMPLE 2 - baseball.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="<xsl:template match="/">
<baseball>
<player>
<xsl:for-each select="baseball/player">
<<xsl:value-of select="id"/> name="<xsl:value-of select="name"/>" team="<xsl:value-of select="team"/>" other="<xsl:value-of select="other"/>"/>
</xsl:for-each>
</player>
</baseball>
</xsl:template>
</xsl:stylesheet>
 
>just need to see how this small example works (or links that explain how this works for us new persons to XML).
Are you suggesting that the example xsl actually works? If yes, I would be interested to know whether you make the xsl or it is taken from some reference document? and it is the latter, where?

>NOTE: When I click on my Example 1 baseball.xml file, I see the following in my webbrowser:
< 1 name="George" team="1" other="" /> < 2 name="Roger" team="2" other="" />< 3 name="Will" team="2" other="Out Sick" />< 4 name="Joe" team="1" other="Left Handed" />

In that case, I would be interested in knowing which webbrowser.
 
Hi tsuji,

I am very much a newbie at this.....I created the xsl file myself in notepad.

Browers used were Firefox 3 and Internet Explorer 8.

Figured that was the easy part - getting the XML into the format that I want is the hard part (at least for me). :)

Jerry
 
Okay. If that xsl is what you make, that's fine to be wrong. If that is taken from some reference, I would be very much upset.

I am also surprised that you say it is ie8 and ff3 that actually display that non-sense. I cannot confirm that and cannot believe that. They are at least more decent to get to that point.

The construction of xsl is not esay I can understand. But, you need to know xml correctly before picking up wrong idea that you've to _unlearn_ one day later.

This cannot be appeared in any well-formed xml:
[tt] <1>...</1>[/tt]
Do you know why?

I can only suggest w3schools---that is not very original and it saves me time to select another---to start learning.
 
Ok - understand. Looks like I need to be able to crawl before I can walk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top