0

I am trying to create a style sheet to format a qgis metadata (qmd) xml document in html. I'm new to the process but have been trying the following and it's not associating the stylesheet appropriately.

The QMD has

<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<?xml-stylesheet href="Sewerage_Manholes_InspectionShafts.xsl" type="text/xsl" ?>
<qgis version="3.9.0-Master">
  <identifier>Z:/My Drive/Mangoesmapping/Spatial Projects/2019/DSC/132_Ongoing_Asset_Updates/Working/Sewerage_Updates/Sewerage_Manholes_InspectionShafts.TAB</identifier>
  <parentidentifier>Sewerage Manhole Infrastructure</parentidentifier>
  <language>AUS</language>
  <type>dataset</type>
  <title>Sewerage Manholes within Douglas Shire Council</title>
  <abstract>Sewerage Manholes within Douglas Shire Council. Most data has been updated based on field work, review of existing AsCon files and discussion with council staff responsible for the assets in 2018/2019. In Port Douglas most of the infrastructure has been surveyed in. </abstract>
  <keywords vocabulary="gmd:topicCategory">
    <keyword>Infrastructure</keyword>
    <keyword>Sewerage</keyword>
  </keywords>
  <keywords vocabulary="undefined 2">
    <keyword>Sewerage</keyword>
  </keywords>
  <keywords vocabulary="undefined 3">
    <keyword>Manholes</keyword>
  </keywords>
  <keywords vocabulary="undefined 4">
    <keyword>Douglas</keyword>
  </keywords>
  <keywords vocabulary="undefined 5">
    <keyword>Queensland</keyword>
  </keywords>
  <contact>
    <name>GIS</name>
    <organization>Douglas Shire Council</organization>
    <position>Finance, Procurement &amp; ICT | Douglas Shire Council</position>
    <voice></voice>
    <fax></fax>
    <email>support.mapping@douglas.qld.gov.au</email>
    <role>Team Leader ICT &amp; Process Improvement</role>
  </contact>
  <links/>
  <history>History</history>
  <fees></fees>
  <rights>Council does not warrant the accuracy of the Data and the Customer
must verify the accuracy of the Data before placing reliance on the Data.</rights>
  <rights>The User indemnifies Council, its employees and agents from any
loss or damage suffered by the Customer or any person or entity, arising
from or in connection with the use/misuse of the Data.</rights>
  <license>The Council is the absolute owner of all intellectual property rights,
including copyright, in the Council’s Data Base (other than DCDB) and
that this Agreement confers no proprietary rights whatsoever in the
Council’s Data Base on the Customer.</license>
  <encoding></encoding>
  <crs>
    <spatialrefsys>
      <proj4>+proj=utm +zone=55 +south +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs</proj4>
      <srsid>2449</srsid>
      <srid>28355</srid>
      <authid>EPSG:28355</authid>
      <description>GDA94 / MGA zone 55</description>
      <projectionacronym>utm</projectionacronym>
      <ellipsoidacronym>GRS80</ellipsoidacronym>
      <geographicflag>false</geographicflag>
    </spatialrefsys>
  </crs>
  <extent>
    <spatial minx="322783.17999999999301508" minz="0" crs="EPSG:28355" maxx="337384.35999999998603016" miny="8170597.66000000014901161" maxz="0" dimensions="2" maxy="8181833.33999999985098839"/>
    <temporal>
      <period>
        <start></start>
        <end></end>
      </period>
    </temporal>
  </extent>
</qgis>

The xsl has

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
    <title>my title</title>

this should be the value from the title tag

</head>
<body>
<h1>Keywords: </h1>    
</body>
    <table style="width:100%;"
        <xsl:for-each select="/keywords>
            <tr>
                <td><xsl:value-of select="keyword"/></td>

Each of the keywords in a table

            </tr>

Value for abstract

        </xsl:for-each>

</html>    
</xsl:template>    
</xsl:stylesheet>

and even this basic code doesn't work -nothing is shown when I load it in a browser.

What am I missing?

Once I do this I want to grab values like "//spatial/@maxx" as well.

GeorgeC
  • 956
  • 5
  • 16
  • 40
  • 1
    It seems your browser will not perform the transformation for security reasons. There have been a number of reports recently complaining about that. – michael.hor257k Jul 26 '19 at 04:52
  • In order to test an stylesheet attached to an XML document by a process instruction, you need to run an http server for those. Otherwise, browser won't open nor transform these documents served by file url protocol. – Alejandro Jul 26 '19 at 22:35
  • @Alejandro -so is there a way to do it without a http server? I was just following the basic process in tutorials like https://www.w3schools.com/xml/xsl_transformation.asp – GeorgeC Jul 26 '19 at 23:47
  • @GeorgeC You have to disable that feature from your browser configuration. See for example https://stackoverflow.com/questions/18586921/how-to-launch-html-using-chrome-at-allow-file-access-from-files-mode – Alejandro Jul 27 '19 at 13:43
  • What's interesting is that the example from w3 above works fine even without changing the configuration - so I don't think this is the issue. There is something in the xml or in the xsl that's not connecting the two correctly. – GeorgeC Jul 29 '19 at 04:27

1 Answers1

1

Try this:-

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    <html>
        <head>
            <title>
                <xsl:value-of select="//title"/>
            </title>
        </head>
        <body>
            <h1>Keywords: </h1>
        <xsl:for-each select="//keywords">
            <table style="width:100%;">
                <tr>
                    <xsl:for-each select="keyword">
                        <td>
                            <xsl:value-of select="current()"/>
                        </td>
                    </xsl:for-each>
                </tr>
            </table>
        </xsl:for-each>
        <xsl:value-of select="//spatial/@maxx"/>
        </body>
    </html>
</xsl:template>
</xsl:stylesheet>
Ajeet Singh
  • 1,056
  • 1
  • 6
  • 21
  • -thanks but it doesn't format properly. If I drag it (the qmd or the same file saved as .xml) into chrome it shows nothing, edge doesn't allow you to drag and drop and firefox just shows all the content without any formatting. I've made the files available in https://drive.google.com/drive/folders/1B2Y6MpHMR8HUPLLvuLGU2FzXUJJn16bn?usp=sharing – GeorgeC Jul 26 '19 at 08:02