html subscript in XML - html

I am trying to use the < sub > < /sub > tag to make parts of my xml file subscripts when opened online but there is an issue when I open up the xml file in Internet Explorer (doesn't say what error just does not look right in IE). I think it is because xml is reading < sub > as another child element but < sub > is just supposed to be used to tell hmtl to make certain parts of the xml file subscripts online. Any ideas on what to change? I am also using xsl to convert xml to html for online publication. The code for that is below
XML File:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="ALDformat.xsl"?>
<ALD_data>
<Element Title = "lithium">
<Element>lithium </Element>
<Compound Subtitle = "Li<sub>2</sub>CO<sub>3</sub>">
<Compound> Li<sub>2</sub>CO<sub>3</sub> </Compound>
<Precursor>
<precursor1> Li(thd) </precursor1>
<precursor2> O<sub>3</sub> </precursor2>
<Ref2> Putkonen2009 </Ref2>
</Precursor>
</Compound>
<Compound Subtitle = "Li<sub>2</sub>O(LiOH)">
<Compound> Li<sub>2</sub>O(LiOH) </Compound>
<Precursor>
<precursor1> Li(O<sup>t</sup>Bu) </precursor1>
<precursor2> H<sub>2</sub>O </precursor2>
<Ref2> Aaltonen2010 </Ref2>
</Precursor>
</Compound>
</Element>
</ALD_data>
XSL File:
<?xml version="1.0" encoding="UTF-8"?>
<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<h1>ALD literature XML database</h1>
<p>Last update: 6 January 2016</p>
<xsl:for-each select="ALDdata/Element">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"> Element: <xsl:value-of select="Element"/> </span>
</div>
<xsl:for-each select="Compound">
<div style="background-color:lightgrey;margin-left:20px;margin-bottom:1em;font-size:10pt">
<p>
<span> Compound: <xsl:value-of select="Compound"/> </span>
</p>
</div>
<xsl:for-each select="Precursor">
<div style="margin-left:30px;margin-bottom:1em;font-size:10pt">
<p>
Precursor 1: <xsl:value-of select="precursor1"/> <br/>
Precursor 2: <xsl:value-of select="precursor2"/>
</p>
Post-2005 review paper references
<ol>
<xsl:for-each select="Ref2">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ol>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</body>
</html>

In order for your sub and sup elements to be processed, you'll have to use xsl:apply-templates instead of xsl:value-of for the elements that contain sub and sup.
I don't think you can use a literal result element as a stylesheet and add templates.
Maybe try something like this instead...
XML Input (Note: I had to remove the values of the Compound/#Subtitle attributes as they are not well-formed.)
<?xml-stylesheet type="text/xsl" href="ALDformat.xsl"?>
<ALD_data>
<Element Title = "lithium">
<Element>lithium </Element>
<Compound Subtitle = "">
<Compound> Li<sub>2</sub>CO<sub>3</sub> </Compound>
<Precursor>
<precursor1> Li(thd) </precursor1>
<precursor2> O<sub>3</sub> </precursor2>
<Ref2> Putkonen2009 </Ref2>
</Precursor>
</Compound>
<Compound Subtitle = "">
<Compound> Li<sub>2</sub>O(LiOH) </Compound>
<Precursor>
<precursor1> Li(O<sup>t</sup>Bu) </precursor1>
<precursor2> H<sub>2</sub>O </precursor2>
<Ref2> Aaltonen2010 </Ref2>
</Precursor>
</Compound>
</Element>
</ALD_data>
XSLT 1.0 (ALDformat.xsl)
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<html>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<h1>ALD literature XML database</h1>
<p>Last update: 6 January 2016</p>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="Element[#Title]">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"> Element: <xsl:apply-templates select="Element"/> </span>
</div>
<xsl:apply-templates select="Compound"/>
</xsl:template>
<xsl:template match="Compound[#Subtitle]">
<div style="background-color:lightgrey;margin-left:20px;margin-bottom:1em;font-size:10pt">
<p>
<span> Compound: <xsl:apply-templates select="Compound"/> </span>
</p>
</div>
<xsl:apply-templates select="Precursor"/>
</xsl:template>
<xsl:template match="Precursor">
<div style="margin-left:30px;margin-bottom:1em;font-size:10pt">
<p>
Precursor 1: <xsl:apply-templates select="precursor1"/> <br/>
Precursor 2: <xsl:apply-templates select="precursor2"/>
</p>
Post-2005 review paper references
<ol>
<xsl:apply-templates select="Ref2"/>
</ol>
</div>
</xsl:template>
<xsl:template match="sub|sup">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="Ref2">
<li><xsl:apply-templates/></li>
</xsl:template>
</xsl:stylesheet>
Output
<html>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<h1>ALD literature XML database</h1>
<p>Last update: 6 January 2016</p>
<div style="background-color:teal;color:white;padding:4px"><span style="font-weight:bold"> Element: lithium </span></div>
<div style="background-color:lightgrey;margin-left:20px;margin-bottom:1em;font-size:10pt">
<p><span> Compound: Li<sub>2</sub>CO<sub>3</sub></span></p>
</div>
<div style="margin-left:30px;margin-bottom:1em;font-size:10pt">
<p>
Precursor 1: Li(thd) <br>
Precursor 2: O<sub>3</sub></p>
Post-2005 review paper references
<ol>
<li> Putkonen2009 </li>
</ol>
</div>
<div style="background-color:lightgrey;margin-left:20px;margin-bottom:1em;font-size:10pt">
<p><span> Compound: Li<sub>2</sub>O(LiOH) </span></p>
</div>
<div style="margin-left:30px;margin-bottom:1em;font-size:10pt">
<p>
Precursor 1: Li(O<sup>t</sup>Bu) <br>
Precursor 2: H<sub>2</sub>O
</p>
Post-2005 review paper references
<ol>
<li> Aaltonen2010 </li>
</ol>
</div>
</body>
</html>

You can't place HTML in a stylesheet right away, your XSLT must have the stylesheet element at the top level, and have template elements as child content, like
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<h1>ALD literature XML database</h1>
<p>Last update: 6 January 2016</p>
<xsl:for-each select="ALDdata/Element">
<!-- ... -->
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I must admit, it's been a while since I used in-browser XSLT. Are you using IE by chance?

Related

XSLT How to print all attributes inside an element: <node id="" name="" random=""></node>

The only answers I come across is how to list the value of the node and child nodes itself. What I would like to know is how I can print all the values inside the node tag itself.
XML (there can be more books within catalog)
<data>
<info>
<catalog Id="1111" Locale="en_GB">
<books>
<book id="01" Name="Title 1" Author="John Doe"></book>
<book id="02" Name="Title 2" Author="Jane Doe"></book>
</books>
What I currently have:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="data/info/catalog">
<xsl:value-of select="#Id" />
<xsl:value-of select="/books/book/#Name"/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Specifically, I would like the output to be:
Catalog Id: 1111
Attributes:
id: 01
Name: Title 1
Author: John Doe
id: 02
Name: Title 2
Author: Jane Doe
The reason it's being done this way because I have dozens upon dozens of values and it's easier to fit them inside the node tag itself instead of creating hundreds of sub-sub-subchilds.
You did not post the exact HTML code you want to have. Try something like:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/data">
<html>
<body>
<xsl:for-each select="info/catalog">
<xsl:text>Catalog Id: </xsl:text>
<xsl:value-of select="#Id" />
<br/>
<br/>
<xsl:text>Attributes:</xsl:text>
<br/>
<xsl:for-each select="books/book">
<xsl:for-each select="#*">
<xsl:value-of select="name()" />
<xsl:text>: </xsl:text>
<xsl:value-of select="." />
<br/>
</xsl:for-each>
<br/>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Missed values while transforming XML into HTMl using XSL

Some of the values of my XML file are not displaying when transformed. Looks like something is not right witn XSL namespaces, but i can't figure it out.
XML file to transform
<?xml-stylesheet type="text/xsl" href="birth_new_3.xsl"?>
<ns2:ROGDINFResponse xmlns="urn://x-artefacts-zags-rogdinf/types/4.0.1"
xmlns:ns2="urn://x-artefacts-zags-rogdinf/root/112-51/4.0.1">
<ns2:ZgsAnswer>
<ns2:BrthReg>
<ns2:BrthLcs>
<SerLcs>II-LP</SerLcs>
<NumLcs>443334</NumLcs>
<DateLcs>1988-03-18</DateLcs>
</ns2:BrthLcs>
<ns2:SvReg>
<ns2:SvRodiv>
<ns2:FIOrogd>
<Last>Last</Last>
<First>Fname</First>
<Middle>Mname</Middle>
</ns2:FIOrogd>
<ns2:BirthDate>1988-01-19</ns2:BirthDate>
<ns2:BirthPlace Place="Some place"/>
</ns2:SvRodiv>
</ns2:SvReg>
</ns2:BrthReg>
</ns2:ZgsAnswer>
</ns2:ROGDINFResponse>
XSL file
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns2="urn://x-artefacts-zags-rogdinf/root/112-51/4.0.1"
xmlns="urn://x-artefacts-zags-rogdinf/types/4.0.1">
<xsl:output method="html"/>
<xsl:template match="/">
<HTML>
<BODY>
<H2>Birth data</H2>
<span>Serial: <b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:BrthLcs/SerLcs"/>
</b>
</span>
<p>
<span>Number: <b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:BrthLcs/NumLcs"/>
</b>
</span>
</p>
<p>
<span>Date: <b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:BrthLcs/DateLcs"/>
</b>
</span>
</p>
<H3>Additional data: </H3>
<span>Last, First, Middle:
<b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:SvReg/ns2:SvRodiv/ns2:FIOrogd/Last"/>
</b>
<b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:SvReg/ns2:SvRodiv/ns2:FIOrogd/First"/>
</b>
<b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:SvReg/ns2:SvRodiv/ns2:FIOrogd/Middle"/>
</b>
</span>
<p>
<span>Date: <b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:SvReg/ns2:SvRodiv/ns2:BirthDate"/>
</b>
</span>
</p>
<p>
<span>Place: <b>
<xsl:apply-templates select="//ns2:ROGDINFResponse/ns2:ZgsAnswer/ns2:BrthReg/ns2:SvReg/ns2:SvRodiv/ns2:BirthPlace/#Place"/>
</b>
</span>
</p>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
Some of the values of my XML are diplaying just fine, but values of the fields without namespaces are not diplaying (SerLcs, NumLcs, DateLcs, Last, First, Middle).
How can i fix my XSL?
Instead of xmlns="urn://x-artefacts-zags-rogdinf/types/4.0.1" in the XSLT you want xpath-default-namespace="urn://x-artefacts-zags-rogdinf/types/4.0.1" in there. Note that this only works with XSLT 2 and 3 processors like Saxon 9 or 10, Saxon-JS 2, XmlPrime, Exselt, AltovaXML.
First, Last, and Middle do have a namespace: they're in namespace urn://x-artefacts-zags-rogdinf/types/4.0.1. In XPath by default an unprefixed name refers to an element in no namespace. You can change this using xpath-default-namespace as #MartinHonnen suggests.

Add hyperlinks for different <place> tags in XML to HTML transformation with XSLT

I have a set of XML files where place names (in divergent historic spelling) are tagged as
<place>: cf. sample file. The place tag also contains the attribute link, whose value is a hyperlink to a World Historical Gazetteer page, e.g.:
<place name="Wien" type="place_of_issue"
link="http://whgazetteer.org/places/12346175/portal">Wien</place>
Converting the XML files to HTML with XSLT, I want every such tag in the text to be replaced by a hyperlink <a href>, linking to the same WHG URL.
A minimal version of my XSL based on Michael Hor-257k's answer is:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<!-- Jekyll statement -->
---
<xsl:for-each select="source/metadata/digital_surrogate">
layout: page
title: <xsl:value-of select="#filename"/>
permalink: /<xsl:value-of select="#filename"/>/
exclude: true
---
</xsl:for-each>
<!-- Get transcription with links -->
<div class="flex-container">
<div><p><strong>Transkription:</strong></p>
<p><xsl:apply-templates select="//div">
</xsl:apply-templates>
<!-- include WHG links -->
<xsl:for-each select="//place">
<p>Genannte Orte im World Historical Gazetteer:</p>
<a href="{//place/#link}" target="_blank">
<xsl:value-of select="."/>
</a><br/>
</xsl:for-each>
</p><br/>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
This at least correctly displays all place names mentioned in the correct order, with correct WHG links and correct names:
Wien
Maintz
Wien
However, the links still appear below the transcription, not within.
My desired HTML output would be:
<div class="flex-container">
<div>
<p><strong>Transkription:</strong></p>
<p>
Wir Vorsteher und gesamte
Meister des ehrsamen Handwerks der bürgerl:[ichen] Tischlern in der K:[aiserlich]
K:[öniglichen] Haubt = und Residenz Stadt Wien (beglaubigen) hiermit,
daß gegenwertiger Tischlergesell, Namens Georg
Gramer von Maintz - -
[etc.]
</p>
</div>
</div>
I am guessing that instead of:
<xsl:variable name="urlPlace">
<xsl:value-of select="#link"/>
</xsl:variable>
<xsl:apply-templates select="//place"/>
you want to do:
<a href="{#link}" target="_blank">
<xsl:value-of select="."/>
</a>
Untested, because no example to test with was provided.
--- added ---
See if you can use this as your starting point:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/source">
<html>
<body>
<xsl:apply-templates select="content/body/div"/>
</body>
</html>
</xsl:template>
<xsl:template match="div">
<p>
<xsl:apply-templates select="text"/>
</p>
</xsl:template>
<xsl:template match="place">
<a href="{#link}" target="_blank">
<xsl:value-of select="."/>
</a>
</xsl:template>
</xsl:stylesheet>
To understand this and adapt it to your needs, you will need to study XSLT's processing model: https://www.w3.org/TR/1999/REC-xslt-19991116/#section-Processing-Model
If you want to transform a place element like <place name="Wien" type="place_of_issue" link="http://whgazetteer.org/places/12346175/portal">Wien</place> into an HTML a element use a template
<xsl:template match="place">
<a href="{#link}">
<xsl:value-of select="."/>
</a>
</xsl:template>
Write templates for the transformation of other elements like the ancestors of the places and make sure these templates process child nodes with <xsl:apply-templates/>.
That way the structure and order of the input should be preserved, only that you have HTML in the output reflecting the semantic XML elements you have in the input.
The two previous answers helped me understand the nesting rules in XSL that I wasn't familiar with.
So here is the full XSL that does exactly what I want:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<!-- BESCHREIBUNG, BILD UND TEXT AUF "SOURCE" EBENE -->
<xsl:template match="source">
<!-- Jekyll statement --> --- <xsl:for-each select="metadata/digital_surrogate">
layout: page title: <xsl:value-of select="#filename"/> permalink: /<xsl:value-of
select="#filename"/>/ exclude: true --- </xsl:for-each>
<!-- Metadaten -->
<xsl:for-each select="metadata/source_description">
<h3>Ausstellungsort: <xsl:value-of select="#place"/></h3>
<h3>Ausstellungsdatum: <xsl:value-of select="#date"/></h3>
</xsl:for-each>
<xsl:for-each select="edition">
<h4 align="center">ediert von: <xsl:value-of select="editors/#name"/></h4>
<h4 align="center">zuletzt bearbeitet: <xsl:value-of
select="transcription_info/#last_revision_date"/></h4>
</xsl:for-each>
<br/>
<xsl:for-each select="metadata/digital_surrogate">
<xsl:variable name="urlVar">
<xsl:value-of select="#URL"/>
</xsl:variable>
<img src="{$urlVar}" valign="top"/>
</xsl:for-each>
<!-- HTML-Flex-Container für Digitalisat und Inhalt -->
<div class="flex-container">
<div>
<p>
<strong>Graphische Elemente:</strong>
</p>
<p>
Art des Siegels: <xsl:value-of select="metadata/source_description/#seal"/>
Sonstiges: <xsl:for-each select="visual_element"/>
</p>
<br/>
</div>
</div>
<hr/>
<div class="flex-container">
<div>
<p>
<strong>Transkription:</strong>
</p>
<p>
<xsl:apply-templates select="content/body/div"/>
</p>
</div>
<div>
<p>
<strong>Übersetzung:</strong>
</p>
<p>
<xsl:apply-templates select="translation"/>
</p>
<br/>
</div>
</div>
</xsl:template>
<!-- WHG LINKS AUF EBENE DIV UND TEXT -->
<xsl:template match="div">
<p>
<xsl:apply-templates select="text"/>
</p>
</xsl:template>
<xsl:template match="place">
<a href="{#link}" target="_blank">
<xsl:value-of select="."/>
</a>
</xsl:template>
</xsl:stylesheet>

Nesting some elements into <div> </div> tags using xslt transformation

I'm new in XSLT. I would like to transform xml to html using xslt. I want to add div elements in which will be nested some attributes based on the condition.
I have following xml:
<xml version="1.0" encoding="UTF-8"?>
<ns:form xmlns:ns="http://abcdefghij/datatypes/">
<ns:sectors>
<ns:sector>
<ns:sectorID>Title</ns:sectorID>
<ns:controls>...</ns:controls>
</ns:sector>
<ns:sector>
<ns:sectorID>Image1</ns:sectorID>
<ns:controls>...</ns:controls>
</ns:sector>
<ns:sector>
<ns:sectorID>Content1</ns:sectorID>
<ns:controls>...</ns:controls>
</ns:sector>
<ns:sector>
<ns:sectorID>Links</ns:sectorID>
<ns:controls>...</ns:controls>
</ns:sector>
<ns:sector>
<ns:sectorID>Buttons</ns:sectorID>
<ns:controls>...</ns:controls>
</ns:sector>
</ns:sectors>
</ns:form>
And I would like to get:
<div id="sablona1" class="override-ckeditor">
<div id="Title">...</div>
<div>
<div id="Image1">...</div>
<div id="Content1">...</div>
<div id="Links">...</div>
</div>
<div id="Buttons">...</div>
</div>
I have tried this xslt:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://abcdefghij/datatypes/" xmlns:xls="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="ns">
<xsl:output method="html" />
<xsl:template match="/ns:form">
<div id="sablona1" class="override-ckeditor">
<xsl:for-each select="ns:sectors/ns:sector">
<!-- starts the code, which is not working -->
<xsl:choose>
<xsl:when test="ns:sectorID = 'Image1'">
<div>
</xsl:when>
<xsl:when test="ns:sectorID = 'Buttons'">
</div>
</xsl:when>
</xsl:choose>
<!-- ends the code, which is not working -->
<div>
<xsl:attribute name="id">
<xsl:value-of select="ns:sectorID"/>
</xsl:attribute>
<xsl:apply-templates select="ns:controls"/>
</div>
</xsl:for-each>
</div>
</xsl:template>
</xsl:stylesheet>
But it returns error:
Unable to generate the XML document using the provided XML/XSL input.
org.xml.sax.SAXParseException; lineNumber: 11; columnNumber: 23; The
element type "div" must be terminated by the matching end-tag
"</div>".
I probably understand what is wrong, but I have no idea how to fix it.
Please could you give me some advices?
Thanks.
XSLT is not a word processor. It works with a node tree, not individual tags. And an XSLT stylesheet must be a well-formed XML document, too.
Try perhaps a different approach:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns="http://abcdefghij/datatypes/"
exclude-result-prefixes="ns">
<xsl:output method="html"/>
<xsl:template match="/ns:form">
<div id="sablona1" class="override-ckeditor">
<div id="Title">
<xsl:value-of select="ns:sectors/ns:sector[1]/ns:controls"/>
</div>
<div>
<xsl:for-each select="ns:sectors/ns:sector[position() > 1]">
<div id="{ns:sectorID}">
<xsl:value-of select="ns:controls"/>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>
</xsl:stylesheet>
Or, if you prefer:
<xsl:template match="/ns:form">
<div id="sablona1" class="override-ckeditor">
<div id="Title">
<xsl:value-of select="ns:sectors/ns:sector[ns:sectorID = 'Title']/ns:controls"/>
</div>
<div>
<xsl:for-each select="ns:sectors/ns:sector[ns:sectorID !='Title']">
<div id="{ns:sectorID}">
<xsl:value-of select="ns:controls"/>
</div>
</xsl:for-each>
</div>
</div>
</xsl:template>

Dynamically change value of in an XSL file

Currently the displaying the XML in a browser along with the XSL data is correct except for one thing. In some colleges I have one department while in orders I have more than one (up to 9). How I can dynamically output the data based on the number of department for each college? Currently it only outputs one department per college.
College.xml File
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="colleges.xsl"?><colleges>
<college id="0">
<school>College of Education</school>
<mission>text</mission>
<department id="0">Educational Psychology and Leadership</department>
<department id="1">Health and Human Performance</department>
<department id="2">Language, Literacy and Intercultural Studies</department>
<department id="3">Teaching, Learning and Innovation</department>
</college>
<college id="1">
<school>College of Nursing</school>
<mission>text</mission>
<department id="0">Nursing</department>
</college>
<college id="2">
<school>School of Business</school>
<mission>text</mission>
<department id="0">Accounting and Management Information Systems</department>
<department id="1">Applied Business Technology</department>
</college></colleges>
College.xsl file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="colleges/college">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="school"/></span> - <br /><xsl:value-of select="mission"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<p>
<xsl:value-of select="department"/><br />
</p>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Try:
<xsl:template match="/"> ...
<xsl:for-each select="colleges/college">
...
<xsl:apply-templates select="department"/>
...
</xsl:for-each>
</xsl:template>
<xsl:template match="department">... what you want for each department</xsl:template>
Give this a shot...
<xsl:template match="/">
<html>
<body style="font-family:Arial;font-size:12pt;background-color:#EEEEEE">
<xsl:for-each select="colleges/college">
<div style="background-color:teal;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="school"/></span> - <br /><xsl:value-of select="mission"/>
</div>
<div style="margin-left:20px;margin-bottom:1em;font-size:10pt">
<p>
<xsl:apply-templates select="department"/>
</p>
</div>
</xsl:for-each>
</body>
</html>
</xsl:template>
<xsl:template match="department">
<xsl:value-of select="."/><br />
</xsl:template>