At 2006-03-24 10:51 -0800, Allison Bloodworth wrote:
When I specify a target namespace for the root element in my XSL document,
e.g. <Events xmlns="urn:cde.berkeley.edu:babl:events:1.00"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:cde.berkeley.edu:babl:events:1.00 UCBEvents.xsd">
it appears that I then need to use a namespace prefix for every element from
that document referenced in my XSL transform.
Correct ... that is conformant behaviour for XSLT 1.
By adding a default namespace at the document element you have just
changed every unprefixed element in the document.
So I can't do this:
<xsl:value-of select="Events/View/FormatCalendar/ShortName"/>
Yes, you cannot, since those are not elements in your namespace.
But instead have to do this:
<xsl:value-of select="ev:Events/ev:View/ev:FormatCalendar/ev:ShortName"/>
Right again. By specification, XPath 1 does not use the default namespace.
This is a huge stylesheet and there are three different stylesheets I'd have
to modify, so to do this MANY changes will have to be made.
Well, you have just made MANY changes to your XML.
I need the
target namespace in my XML document if I want to validate it. Is there any
way around modifying all my XSLs?
You could write a pre-processing stylesheet that strips all
namespaces from the input and then apply the resulting instance with
elements in no namespace against your existing stylesheets. That way
you run your raw instances for validation and your processed
instances for formatting.
A modification of the identity stylesheet would do ... I hope the
code below helps.
. . . . . . . . . . Ken
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="text()|comment()|processing-instruction()">
<xsl:copy/>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name(.)}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name(.)}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--