[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Target Namespace in XML breaks XSL transform
At 2006-03-24 10:51 -0800, Allison Bloodworth wrote:
When I specify a target namespace for the root element in my XSL document, 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>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|