How to rendering tricky XML schema

Posted on 2004-11-01
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
    LVL 3

    Accepted Solution

    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:

      <!-- 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()" />


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API ( has made its way into the popular lexicon of the English language.  A few years ago, …
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    933 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now