Help with XSLT

Here should go questions about transforming XML with XSLT and FOP.
philoxygen
Posts: 3

Help with XSLT

Fri Nov 21, 2014 9:30 pm

Hi, I am trying for the first time to get an XML and an XSLT to "talk" to each other - I think I am pretty close, but I am struggling to understand something that I think is namespace related perhaps? When in run the XML, I either get a blank page or all the data returned, not the selection I specify. I have tried numerous ways, would be grateful for some help here please, it's prob one step I am missing that's all - thanks a lot

I hope this comes out ok with the code tags. I should say in advance it is a homework - not looking for the solution, just want to understand why the XMLST transformation does not return my selection, that's enough of a leg up.

thanks for the help
phil

Code: Select all

<xsl:stylesheet version="2.0"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ins="http://cs.swansea.ac.uk/~cspj/driving"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:template match="ins:directions">
    <html>
      <head> 
   <title>test</title>     
      </head>
      <body>
      <table border="1">
          <xsl:apply-templates select="ins:start"/>
       </table>
      </body>
    </html>

 
  <xsl:template match="ins:start">
    <tr>
      <td>
        <h1><xsl:value-of select="ins:street"/></h1>
        <i><xsl:value-of select="ins:city"/></i>
        <ul><xsl:apply-templates select="ins:state"/></ul>       
      </td>
    </tr>
  </xsl:template>
   
 
  </xsl:stylesheet>


Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="driving.xsl"?>
<ins:directions xmlns:ins="http://cs.swansea.ac.uk/~cspj/driving">

  <ins:start>
    <ins:street>W Mahoning St</ins:street>
    <ins:city>Punxsutawney</ins:city>
    <ins:state>PA</ins:state>
    <ins:zip>15767</ins:zip>
    <ins:country>US</ins:country>
  </ins:start>

  <ins:end>
    <ins:street>1600 Pennsylvania Ave Nw</ins:street>
    <ins:city>Washington</ins:city>
    <ins:state>DC</ins:state>
    <ins:country>US</ins:country>
  </ins:end>

  <ins:estimate>
    <ins:time><ins:hours>4</ins:hours><ins:minutes>33</ins:minutes></ins:time>
    <ins:distance>246.68</ins:distance>
  </ins:estimate>

  <ins:route>

    <ins:step id="1" type="initial">
      <ins:direction>NORTHWEST</ins:direction>
      <ins:on>PA-36</ins:on>
      <ins:on>N MAIN ST</ins:on>
      <ins:toward>LINCOLN AVE</ins:toward>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

    <ins:step id="2" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>LINCOLN AVE</ins:onto>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="3" type="becomes">
      <ins:old>LINCOLN AVE</ins:old>
      <ins:new>PA-436</ins:new>
      <ins:distance>1.7</ins:distance>
    </ins:step>

    <ins:step id="4" type="turn">
      <ins:direction>RIGHT</ins:direction>
      <ins:onto>US-119 S</ins:onto>
      <ins:onto>BUFFALO-PITTSBURGH HWY</ins:onto>
      <ins:distance>27.9</ins:distance>
    </ins:step>

    <ins:step id="5" type="merge">
      <ins:onto>US-422 E</ins:onto>
      <ins:via>EXIT A</ins:via>
      <ins:toward>EBENSBURG</ins:toward>
      <ins:distance>27.7</ins:distance>
    </ins:step>

    <ins:step id="6" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>ramp</ins:onto>
      <ins:distance>0.1</ins:distance>
    </ins:step>

    <ins:step id="7" type="merge">
      <ins:onto>US-22 E</ins:onto>
      <ins:onto>WILLIAM PENN HWY</ins:onto>
      <ins:distance>17.1</ins:distance>
    </ins:step>

    <ins:step id="8" type="merge">
      <ins:onto>I-99</ins:onto>
      <ins:onto>US-220 S</ins:onto>
      <ins:toward>BEDFORD</ins:toward>
      <ins:distance>27.6</ins:distance>
    </ins:step>

    <ins:step id="9" type="take">
      <ins:direction>EXIT 1</ins:direction>
      <ins:toward>I-70</ins:toward>
      <ins:toward>PENNSYLVANIA TURNPIKE</ins:toward>
      <ins:toward>BEDFORD</ins:toward>
      <ins:distance>0.9</ins:distance>
    </ins:step>

    <ins:step id="10" type="turn">
      <ins:direction>SLIGHT RIGHT</ins:direction>
      <ins:onto>US-220 BR</ins:onto>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="11" type="merge">
      <ins:onto>I-76 E</ins:onto>
      <ins:onto>PENNSYLVANIA TURNPIKE</ins:onto>
      <ins:onto>I-70 E</ins:onto>
      <ins:toward>HARRISBURG</ins:toward>
      <ins:toward>EXITS 12-39</ins:toward>
      <ins:distance>16.0</ins:distance>
    </ins:step>

    <ins:step id="12" type="merge">
      <ins:onto>I-70 E</ins:onto>
      <ins:via>EXIT 161</ins:via>
      <ins:toward>US-30</ins:toward>
      <ins:toward>BALTIMORE</ins:toward>
      <ins:toward>WASHINGTON D C</ins:toward>
      <ins:toward>BREEZEWOOD</ins:toward>
      <ins:distance>2.1</ins:distance>
    </ins:step>

    <ins:step id="13" type="take">
      <ins:direction>US-30 W exit</ins:direction>
      <ins:distance>0.1</ins:distance>
    </ins:step>

    <ins:step id="14" type="turn">
      <ins:direction>RIGHT</ins:direction>
      <ins:onto>I-70</ins:onto>
      <ins:onto>US-30</ins:onto>
      <ins:onto>LINCOLN HWY</ins:onto>
      <ins:distance>0.3</ins:distance>
    </ins:step>

    <ins:step id="15" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>I-70 E</ins:onto>
      <ins:distance>75.9</ins:distance>
    </ins:step>

    <ins:step id="16" type="merge">
      <ins:onto>I-270 S</ins:onto>
      <ins:via>EXIT 53</ins:via>
      <ins:toward>WASHINGTON</ins:toward>
      <ins:distance>30.0</ins:distance>
    </ins:step>

    <ins:step id="17" type="take">
      <ins:direction>I-270 SPUR S</ins:direction>
      <ins:toward>toward I-495 S</ins:toward>
      <ins:toward>NORTHERN VIRGINIA</ins:toward>
      <ins:distance>2.0</ins:distance>
    </ins:step>

    <ins:step id="18" type="merge">
      <ins:onto>CAPITAL BELTWAY</ins:onto>
      <ins:onto>I-495 S</ins:onto>
      <ins:distance>3.7</ins:distance>
    </ins:step>

    <ins:step id="19" type="take">
      <ins:direction>VA-193 exit- EXIT 43-44-</ins:direction>
      <ins:toward>GEORGE WASHINGTON MEMORIAL PKWY</ins:toward>
      <ins:toward>GEORGETOWN PIKE</ins:toward>
      <ins:distance>0.3</ins:distance>
    </ins:step>

    <ins:step id="20" type="merge">
      <ins:onto>GEORGE WASHINGTON MEMORIAL PKWY S</ins:onto>
      <ins:via>EXIT 43</ins:via>
      <ins:distance>8.7</ins:distance>
    </ins:step>

    <ins:step id="21" type="take">
      <ins:direction>US-29 N exit</ins:direction>
      <ins:toward>KEY BRIDGE</ins:toward>
      <ins:toward>WASHINGTON</ins:toward>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="22" type="turn">
      <ins:direction>SLIGHT RIGHT</ins:direction>
      <ins:onto>N LYNN ST</ins:onto>
      <ins:onto>US-29 N</ins:onto>
      <ins:continue>US-29 N</ins:continue>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="23" type="turn">
      <ins:direction>SLIGHT RIGHT</ins:direction>
      <ins:onto>ramp</ins:onto>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

    <ins:step id="24" type="merge">
      <ins:onto>US-29 N</ins:onto>
      <ins:onto>WHITEHURST FWY</ins:onto>
      <ins:distance>0.4</ins:distance>
    </ins:step>

    <ins:step id="25" type="take">
      <ins:direction>ramp</ins:direction>
      <ins:toward>ROCK CREEK PARKWAY</ins:toward>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="26" type="merge">
      <ins:onto>POTOMAC RIVER FWY S</ins:onto>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="27" type="take">
      <ins:direction>I-66 W</ins:direction>
      <ins:direction>E ST exit</ins:direction>
      <ins:toward>JF KENNEDY CENTER</ins:toward>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

    <ins:step id="28" type="take">
      <ins:direction>E STREET exit on the LEFT</ins:direction>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="29" type="stay">
      <ins:direction>STRAIGHT</ins:direction>
      <ins:onto>E ST EXPY</ins:onto>
      <ins:distance>0.3</ins:distance>
    </ins:step>

    <ins:step id="30" type="stay">
      <ins:direction>STRAIGHT</ins:direction>
      <ins:onto>E ST NW</ins:onto>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

    <ins:step id="31" type="turn">
      <ins:direction>RIGHT</ins:direction>
      <ins:onto>19TH ST NW</ins:onto>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="32" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>CONSTITUTION AVE NW</ins:onto>
      <ins:onto>US-50</ins:onto>
      <ins:distance>0.3</ins:distance>
    </ins:step>

    <ins:step id="33" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>16TH ST NW</ins:onto>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

    <ins:step id="34" type="turn">
      <ins:direction>LEFT</ins:direction>
      <ins:onto>ELLIPSE RD NW</ins:onto>
      <ins:distance>0.2</ins:distance>
    </ins:step>

    <ins:step id="35" type="turn">
      <ins:direction>SLIGHT RIGHT</ins:direction>
      <ins:onto>E ST NW</ins:onto>
      <ins:distance>&lt;0.1</ins:distance>
    </ins:step>

  </ins:route>
</ins:directions>
philoxygen
Posts: 3

my last post re help with xslt

Fri Nov 21, 2014 10:32 pm

Please disregard- I have sorted it myself just now :)
philoxygen
Posts: 3

xml with xslt

Fri Nov 21, 2014 10:41 pm

if it helps anyone I was just missing

</xsl:template>

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest