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

unwanted noNamespaceSchemaLocation?

Subject: unwanted noNamespaceSchemaLocation?
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Wed, 15 Sep 2010 00:44:06 +1200
 unwanted noNamespaceSchemaLocation?
Hi

I have a number of separate XML files which each have <document> as their
outermost node. A document element might look like this:

  <document
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="../../util/docs.xsd"
    version="1.80"
  >
    ...
  </document>

Documents may contain <include> elements, which point to other documents.
Thus:

  <document ..>
    <title>Test Document</title>
    <include srcfile="intro.xml"/>
    <include srcfile="middle.xml"/>
    <include srcfile="end.xml"/>
  </document>

where each of the XML documents referred to in the srcfile attributes have
the same schema declaration as the outer document.

We have a particular XML stylesheet which processes a document and creates
an expanded version which contains all included documents in the single
file; in this document the (sub)documents are children of <included>
elements.

A minimal version of the expand.xsl stylesheet is as follows:

  <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="UTF-8" />
  
  <xsl:template match="/">
    <xsl:apply-templates>
      <xsl:with-param name="currdoc" />
    </xsl:apply-templates>
  </xsl:template>
  
  <!-- Content of include'd subfiles inside an includED element -->
  <xsl:template match="include">
    <xsl:param name="currdoc" />
    <xsl:element name="included">
      <xsl:attribute name="srcfile">
        <xsl:value-of select="@srcfile" />
      </xsl:attribute>
      <xsl:apply-templates select="document(@srcfile)/*">
        <xsl:with-param name="currdoc" select="@srcfile" />
      </xsl:apply-templates>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="*">
    <xsl:param name="currdoc" />
  <!-- don't want to copy namespace nodes, hence <xsl:element> instead of
<xsl:copy> -->
    <xsl:element name="{name()}">
      <xsl:apply-templates select="@*" />
      <xsl:apply-templates select="node()">
        <xsl:with-param name="currdoc" select="$currdoc" />
      </xsl:apply-templates>
    </xsl:element>
  </xsl:template>
  
  <xsl:template match="@*">
    <xsl:copy />
  </xsl:template>

My question is, how can I eliminate the
   xsi:noNamespaceSchemaLocation="../../util/docs.xsd"
attribute from all the lower level <document> elements?

The stylesheet must be XSL 1.0 because that's a restriction of one of the
environments in which it runs (although if there is an XSL2 solution I would
be interested in it for the future).

Cheers
Trevor

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.