[oXygen-user] Correct XPath expression to get title nexted in xhtml <span>'s

McGibbney, Lewis John Lewis.McGibbney at gcu.ac.uk
Mon Feb 27 07:51:35 CST 2012


Hi,

Whilst working on xhtml --> xml xslt I've run into a blocker when trying to specify the XPath expression to get a title embedded within nested xhtml <span>'s. A snippet from the body of my xhtml is below:

<body>
  <a name="gen01" id="gen01"></a><div id="content">
                <div id="page1" class="page css-gen1">
                        <div style="width:150pt;height:12pt;left:34pt;top:33pt">
                                <div style="top:9pt">
                                        <span class="css-gen2">
                                                <span>domestic | general | application | 2010</span>
                                        </span>
                                </div>
                        </div>
                        <div style="width:65pt;height:61pt;left:34pt;top:69pt">
                                <div style="top:11pt">
                                        <span class="css-gen3">
                                                <span class="css-gen4">Application</span>
                                        </span>
                                </div>
...

And so far my xsl looks like

<xsl:stylesheet
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ukm="http://www.legislation.gov.uk/namespaces/metadata"
    xmlns:ukl="http://www.legislation.gov.uk/namespaces/legislation"
    xmlns:dc="http://purl.org/dc/elements/1.1"
    xmlns:dct="http://purl.org/dc/terms"
    xmlns:atom="http://www.w3.org2005/Atom"
    xmlns:html="http://www.w3.org/1999/xhtml"
    xsi:schemaLocation="http://www.legislation.gov.uk/namespaces/legislation
    http://www.legislation.gov.uk/schema/schemaLegislationBase-v1-0.xsd"
    xml:base="http://www.legislation.gov.uk/id/ssi/2011/120"
    exclude-result-prefixes="xs xd"
    version="2.0" >
    <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
    <xsl:strip-space elements="*"/>
    <xd:doc scope="stylesheet">
        <xd:desc>
            <xd:p><xd:b>Created on:</xd:b> Feb 21, 2012</xd:p>
            <xd:p><xd:b>Author:</xd:b> lewismc</xd:p>
            <xd:p></xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="/">
        <Legislation>
            <xsl:apply-templates select="html:html"/>
        </Legislation>
    </xsl:template>
    <xsl:template match="html:html/html:body">
        <Secondary>
            <Body DocumentURI="" IdURI="" NumberOfProvisions="">
                <P1group>
                    <Title>
                        <xsl:value-of select="html:a/html:div/html:div/html:div/html:span/html:span"/>
                    </Title>

I know this looks ridiculous, (I've tried many XPath combinations) so apologies in advance for anyone that either laughing or crying whilst viewing this.
Basically, I would like to get as output

<Secondary>
  <Body NumberOfProvisions="" IdURI="" DocumentURI="">
    <P1group>
      <Title>domestic | general | application | 2010</Title>

Anyone that could give me a pointer would make me very happy.

Kind Regards and thank you in advance.

Lewis

Glasgow Caledonian University is a registered Scottish charity, number SC021474

Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009.
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html

Winner: Times Higher Education’s Outstanding Support for Early Career Researchers of the Year 2010, GCU as a lead with Universities Scotland partners.
http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,15691,en.html


More information about the oXygen-user mailing list