Note that there are some explanatory texts on larger screens.

plurals
  1. POusing xslt how do i address this particular element in an xml file?
    primarykey
    data
    text
    <p>Never coded for XML before, totally lost with the various primers which all tell me to do something different. Which probably means you can do it different ways, but they all show single node situations and this isn't.</p> <p>I've tried various ways to pick out the WebDisplayPeriod but im convinced im not actually targetting the attribute of that one right. Would love someone to give me a push in the right direction please. also any readable primers on more advanced use of XSLT would be appreciated as w3schools is rubbish ;) .</p> <p>I've got the following xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;nr:RTPPMDataMsgV1 owner="Network Rail" timestamp="2010-08-05T10:27:04.0Z" classification="public" xsi:schemaLocation="http://xml.networkrail.co.uk/ns/2007/NR rtppm_messaging_v1.17.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msg="http://xml.networkrail.co.uk/ns/2007/EAI" xmlns:nr="http://xml.networkrail.co.uk/ns/2007/NR"&gt; &lt;msg:Sender application="RTPPM3" organisation="String"/&gt; &lt;msg:Publication&gt; &lt;msg:TopicID&gt;RTPPM3/InternalPPM&lt;/msg:TopicID&gt; &lt;/msg:Publication&gt; &lt;nr:RTPPMData snapshotTStamp="2010-08-05T10:27:02.0Z"&gt; &lt;nr:SystemMsg/&gt; &lt;nr:RAGThresholds type="TOC" medium="87" good="92"/&gt; &lt;nr:RAGThresholds type="FOC" medium="70" good="80"/&gt; &lt;nr:RAGThresholds type="PPT" medium="85" good="91"/&gt; &lt;nr:WebPPMLink&gt;http://connect/Performance/PPM/PPMGuide.doc x&lt;/nr:WebPPMLink&gt; &lt;nr:PPT rag="G" ragDisplayFlag="Y"&gt;93&lt;/nr:PPT&gt; &lt;nr:NationalPage WebDisplayPeriod="60"&gt; &lt;nr:WebFixedMsg1&gt;^&amp;lt;5 mins; *&amp;lt;10 mins&lt;/nr:WebFixedMsg1&gt; &lt;nr:WebFixedMsg2&gt;The Public Performance Measure shows the performance of trains against the timetable, measured as the percentage of trains arriving at destination &amp;apos;on time&amp;apos;. &lt;/nr:WebFixedMsg2&gt; &lt;nr:WebMsgOfMoment&gt;EC: 1S02 train defect at Balne.&lt;/nr:WebMsgOfMoment&gt; &lt;nr:StaleFlag&gt;N&lt;/nr:StaleFlag&gt; &lt;nr:NationalPPM&gt; &lt;nr:Total&gt;5079&lt;/nr:Total&gt; &lt;nr:OnTime&gt;4842&lt;/nr:OnTime&gt; &lt;nr:Late&gt;237&lt;/nr:Late&gt; &lt;nr:CancelVeryLate&gt;47&lt;/nr:CancelVeryLate&gt; &lt;nr:PPM rag="G" ragDisplayFlag="N"&gt;95&lt;/nr:PPM&gt; &lt;nr:RollingPPM trendInd="-" rag="G"&gt;94&lt;/nr:RollingPPM&gt; &lt;/nr:NationalPPM&gt; ...... </code></pre> <p>it goes on and on. but the bit im interested in is in the section above. </p> <p>I'm using the following XSLT to turn it into a legible webpage:</p> <pre><code>&lt;?xml version="1.0" ?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xsi:schemaLocation="http://xml.networkrail.co.uk/ns/2007/NR rtppm_messaging_v1.6.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:msg="http://xml.networkrail.co.uk/ns/2007/EAI" xmlns:nr="http://xml.networkrail.co.uk/ns/2007/NR" &gt; &lt;xsl:output method="html" omit-xml-declaration="yes" indent="yes" /&gt; &lt;xsl:param name="mode"&gt;TOCPage&lt;/xsl:param&gt; &lt;xsl:param name="location"&gt;internal-connect&lt;/xsl:param&gt; &lt;xsl:param name="table1Count"&gt;11&lt;/xsl:param&gt; &lt;xsl:param name="table2Count"&gt;23&lt;/xsl:param&gt; &lt;!-- Root template--&gt; &lt;xsl:template match="/nr:RTPPMDataMsgV1/nr:RTPPMData"&gt; &lt;xsl:element name="{nr:NationalPage}"&gt; &lt;xsl:attribute name="{WebDisplayPeriod}" &gt; &lt;xsl:value-of select="."/&gt; &lt;/xsl:attribute&gt; &lt;/xsl:element&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="content-type" CONTENT="text/css" /&gt; &lt;meta http-equiv="expires" CONTENT="-1" /&gt; &lt;meta http-equiv="pragma" CONTENT="no-cache" /&gt; &lt;meta http-equiv="cache-control" CONTENT="no-cache" /&gt; &lt;meta http-equiv="refresh" name="refresh" content="{$WebDisplayPeriod}" /&gt; &lt;title&gt;EC RTPPM Feed&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="stylesheet.css" /&gt; &lt;link rel="stylesheet" type="text/css" href="xslstylesheet.css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Hello&lt;/p&gt; &lt;p&gt;Hello&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; &lt;/xsl:template &gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>and as youve guessed, it never picks up the WebDisplayPeriod. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload