Jump to content

newbie! problem with localisation


JurafskyStef

Recommended Posts

Hello all! I've this xml file

<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="esametest.xsl"?><site><regions><europe>	   <item id="item0">	<location>United States</location>	<quantity>1</quantity>	<name>dueteous nine eighteen</name>	<payment>Credicard</payment>	<description>	<parlist>	<listitem>	<text>fghj<keyword>ghjkg</keyword></text>	</listitem>	<listitem>	<text>fghjgfjhgf</text>	</listitem>	</parlist>	</description>	<shipping>Will ship internationally, see description for charges</shipping>	<incattegory category="category540"/>	<incattegory category="category418"/>	<mailbox>	<mail>	<from>Libero Rive mailto:Rive@hitachi.com</from>	<to>Benidikte Glew mailto:Glew@sds.no</to>	<date>08/05/1999</date>	</mail>	</mailbox>	</item>	<item id="item1">	<location> Moldova,Republic Of </location>	<quantity>1</quantity>	<name>condemn</name>	<payment>Money order,Creditcard,Cash</payment>	<description>	<text>ggjhljkhllkjhkh</text>	</description>	<shipping>Will ship only within country, see description for charges</shipping>	<incattegory category="category966"/>	<incattegory category="category488"/>	<incattegory category="category741"/>	<mailbox>	<mail>	<from>Javam Suwanda mailto:Suwanda@gmu.edu</from>	<to>Mehrdad Glew mailto:Glew@cohera.com</to>	<date>11/28/1999</date>	</mail>	</mailbox>	</item></europe></regions><people>		<person id="person21337">		<name>Cedric Truscott</name>	   <emailadress>mailto:Truscott@ualberta.ca</emailadress>	   <credicard>7035 9867 9348 9586</credicard>	   <profile income="36231.86">	   <interest category="category390"/>	<interest category="category851"/>	<education>College</education>	<business>No</business>	</profile>	<watches>	<watch open_auction="open_auction2188"/>	</watches>	</person>  	<person id="person21338">	<name>Urban Rosencrans</name>	<emailadress>mailto:Rosencrans@edu.hk</emailadress>	<phone>+68(987)78805084</phone>	<address>	<street>38 Motoki St</street>	<city>Moscow</city>	<country>United States</country>	<zipcode>17</zipcode>	</address>	<creditcard>7312 7037 5289 9748</creditcard>	<watches>	<watch open_auction="open_auction2187"/>	<watch open_auction="open_auction2188"/>	</watches>	</person></people><open_auctions>	  <open_auction id="open_auction2187">	  <initial>101.80</initial>	  <reserve>221.72</reserve>	  <bidder>	  <date>07/07/1999</date>	  <time>22:51:</time>	  <personref  person="person21337"/>	  <increase>4.50</increase>	  </bidder>	  <current>106.30</current>	  <itemref  item="item0"/>	  <seller person="person12397"/>	  <annotation>	  <author person="person10286"/>	  <description>	  <text>poiuytrezasdfghjkk</text>	  </description>	  <happiness>3</happiness>	  </annotation>	  <quantity>2</quantity>	  <type>Featured</type>	  <interval>	  <start>07/26/2000</start>	  <end>11/09/1999</end>	 </interval>	 </open_auction>		 <open_auction id="open_auction2188">	 <initial>78.23</initial>	 <bidder>	 <date>03/05/1998</date>	 <time>14:00:51</time>	 <personref  person="person21338"/>  <increase>16.50</increase>  </bidder>  <current>94.73</current>  <privacy>No</privacy>  <itemref item="item1"/>  <seller person="person14886"/>  <annotation>  <author person="person21737"/>  <description>  <text> iuopiu<bold>iiuiuy</bold>ghfg</text>  </description>  <hapiness>8</hapiness>  </annotation>  <quantity>1</quantity>  <type>Featured</type>  <interval>  <start>07/05/2000</start>  <end>12/21/2000</end>  </interval>  </open_auction></open_auctions>   <closed_auctions>	 <closed_auction>	 <seller person="person14861"/>	 <buyer  person="person9374"/>	 <itemref item="item19545"/>	 <price>54.17</price>	 <date>11/07/1988</date>	 <quantity>1</quantity>	 <type>Regular</type>	 <annotation>	 <author  person="person2043"/>	 <description>	 <text>vvvvvvv<bold>hghfjkiuyt</bold>jhggfffff</text>  </description>  <hapiness>9</hapiness>  </annotation>  </closed_auction></closed_auctions> </site>

I would like to display just the address of the second person. I try in different ways... The first was:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match = "/"><xsl:value-of select = "site/people/person[2]/address"/></xsl:template></xsl:stylesheet>

but it doesn't work. the second was:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match = "/">  <xsl:for-each select = "site/people">   <xsl:value-of select = "person[2]/address"/>  </xsl:for-each> </xsl:template></xsl:stylesheet>

and it worked! What are the differences? Why doesn't work the first?Thank you!

Edited by JurafskyStef
Link to comment
Share on other sites

It sounds as if there were multiple <people> elements (or it seems to be expecting multiple people elements). If you just say <people> and there's more than one <people> it wouldn't know which one to select. A foreach loop will go through all of them.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...