[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Namespace and key function issue?

Subject: Namespace and key function issue?
From: russurquhart1@xxxxxxxxxxx
Date: Tue, 12 Oct 2010 15:22:18 -0500 (CDT)
 Namespace and key function issue?
Hi All,

I have a problem, that i believe is related to namespaces, but as those are still pretty new to me, i can't figure this out.

I have an open office xml document of the following:

<?xml version='1.0' encoding="utf-8"?>
<office:document-content>... 
<office:automatic-styles>... 
<style:style style:name="T6" style:family="text">
  <style:text-properties style:text-position="0% 100%" />
</style:style>
<style:style style:name="T7" style:family="text">
  <style:text-properties style:text-position="0% 100%" fo:font-weight="bold"
  style:font-weight-asian="bold" style:font-weight-complex="bold" />
</style:style>
...
</office:automatic-styles>
<office:body>
... 
<text:p text:style-name="P1">
  <text:span text:style-name="T21">Legend(norm): V</text:span>
  <text:span text:style-name="T2">sub</text:span>
  <text:span text:style-name="T7">Bold</text:span>
  <text:span text:style-name="T8">V</text:span>
  <text:span text:style-name="T9">Italic</text:span>
  <text:span text:style-name="T15">V</text:span>
  <text:span text:style-name="T3">sub-bold</text:span>
</text:p>
...
</office:body>
</office:document-content>

My stylesheet, which is based on the open office docbook export xsl, is of the following form:


<xsl:stylesheet version="1.0" xmlns:style="http://openoffice.org/2000/style"
xmlns:text="http://openoffice.org/2000/text"
xmlns:office="http://openoffice.org/2000/office"
xmlns:table="http://openoffice.org/2000/table"
xmlns:draw="http://openoffice.org/2000/drawing"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:meta="http://openoffice.org/2000/meta"
xmlns:number="http://openoffice.org/2000/datastyle"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:chart="http://openoffice.org/2000/chart"
xmlns:dr3d="http://openoffice.org/2000/dr3d"
xmlns:math="http://www.w3.org/1998/Math/MathML"
xmlns:form="http://openoffice.org/2000/form"
xmlns:script="http://openoffice.org/2000/script"
xmlns:config="http://openoffice.org/2001/config" office:class="text"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="office meta table number dc fo xlink chart math script xsl draw svg dr3d form config text style">

  <xsl:output method="xml" indent="yes" omit-xml-declaration="no" version="1.0"
  encoding="UTF-8" doctype-public="-//OASIS//DTD DocBook XML V4.1.2//EN"
  doctype-system="http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" />
  
    <!-- My key function to return the style:style element based on the style:name attribute. -->
  <xsl:key name="style:find_style" match="style:style" use="@style:name" />
  <!-- My template is this: -->
  <xsl:template match="text:span">
    <xsl:choose>
      <xsl:when test="key ('style:find_style', @text:style-name)/style:text-properties/@fo:font-weight='bold'">

        <xsl:element name="Emphasis">
          <xsl:attribute name="type">
            <xsl:text>bold</xsl:text>
          </xsl:attribute>
          <xsl:value-of select="." />
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

This template, which i've isolated, based on the @text:style-name attribure value, looks into the style:style element and determines from its style:text-properties' @fo:font-weight attribute to see if the font style is bold.

However, when i run this, inside of open office, the test fails. In tests, where i've run the code, without a test, nothing is returned.

I added the style: namespace prefix, thinking that would fix the problem, but no luck.

Can anyone give me some insight on how to get this to work?

Thanks again!

Russ

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.