How to rendering tricky XML schema

Posted on 2004-11-01
Medium Priority
Last Modified: 2013-11-19
My XML document is as follows:

      <xs:schema id="NewDataSet">
      <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="sv-SE">
      <xs:choice maxOccurs="unbounded">
      <xs:element name="Table">
<xs:element name="Origin" type="xs:string" minOccurs="0"/>
      <Table diffgr:id="Table1" msdata:rowOrder="0">
<Origin>Göteborg/Landvetter GOT</Origin>
      <Table diffgr:id="Table2" msdata:rowOrder="1">
<Origin>Helsingborg/Ängelholm AGH</Origin>
      <Table diffgr:id="Table3" msdata:rowOrder="2">
<Origin>Helsinki/Vantaa HEL</Origin>
      <Table diffgr:id="Table4" msdata:rowOrder="3">
<Origin>Malmö/Sturup MMX</Origin>
      <Table diffgr:id="Table5" msdata:rowOrder="4">
<Origin>Stockholm/Arlanda ARN</Origin>

What I would like is a piece of XSL that loops through the list of tags called "<Origin>".

Thanks in advance.
Question by:ribbegrd
1 Comment

Accepted Solution

DitmarBehn earned 500 total points
ID: 12464783
Hi ribbegrd,
this should do the trick (note that there are three different ways within the following XLS)

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:diffgr='mydiffgr' >
*** Author:    Ditmar Behn
*** Date:      2004-11-01
*** Origin:    www.experts-exchange.com

  <!-- Start the pattern matching mechanism in the root element -->
  <xsl:template match="/">
      <!-- Either find all occurances of 'Origin' anywhere -->
      <xsl:for-each select="//Origin">
        <xsl:value-of select="text()" />

      <!-- or state explicitly the nodetree location -->
      <xsl:for-each select="DataSet/diffgr:diffgram/NewDataSet/Table/Origin">
        <xsl:value-of select="text()" />


  <!-- or use pattern matching (document order) to be called by xsl:apply-template -->
  <xsl:template match="Origin">
    <xsl:value-of select="text()" />


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question