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

Namespaces and XSD

Subject: Namespaces and XSD
From: "Craig Sampson craig.sampson@xxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Dec 2014 20:52:27 -0000
 Namespaces and XSD
Hi,
  I've been using DTDs with my XML for years. Now I am trying to replace one
of my DTDs with an XSD. I've been told that the root element of the XML I am
outputting from an XSLT transform should have a namespace that corresponds to
the targetNamespace of my schema.

  So far so good. I output the root element with the namespace. But now some
of the child elements are being output with xslns="". I've tried everything I
can think of to eliminate this extra namespaces from being output. (I am
running SAXON EE and using XSLT 2.0)

  I've tried adding xpath-default-namespace= to the value of the
targetNamespace. I've tried it with "". Neither work.
  I've tried replacing generized template matches, using copy, with specific
templates that specify which attributes to output.

  I finally removed the namespace from the root element so it's not output
anymore. Now I have no extraneous namespaces in my output. But, how will the
output XML file know which schema defines it?

  How can I get rid of the unwanted namespace?

  Is there another way to reference the schema (XSD) from the XML document
without adding a namespace to the root element?

Thanks,
  Craig

  Here's a snippet of the XML source file I am transforming:
<?xml version="1.0" encoding="UTF-8"?>
<!--Arbortext, Inc., 1988-2012, v.4002-->
<!DOCTYPE refDictEntry PUBLIC "-//SAS//DTD authoring 13.0//EN"
"authoring.dtd">
<refDictEntry docAlias="lefunctionsref"
eid="p0xkrj83an7dknn1sgukpmnphcje" type="function" xml:lang="en">
<commandLineHelpEntry
eid="p05b61n8f36dwgn1gs1h1l6biwuj">ABS</commandLineHelpEntry>
<indexEntry includeInSyntaxIndex="yes"><?Pub Dtl?><primary><?Pub Dtl?>ABS
function</primary></indexEntry><indexEntry><?Pub Dtl?><primary><?Pub
Dtl?>absolute
value</primary></indexEntry>
<title>ABS Function</title>
<shortDescription>Returns the absolute value.</shortDescription>
<summary>
<category>Mathematical</category>
</summary>
<syntax eid="p07w43trquf74on1ct3ur17des7e">
<syntaxSimple eid="p005cpxu5su0dkn1b6to129kl254">
<syntaxLevel><keyword>ABS</keyword>(<userSuppliedSyntaxValue
link="p1shy0v9fx5303n11p04kh3zsvm3">argument</userSuppliedSyntaxValue>)</synt
axLevel>
</syntaxSimple>

Here's the title template so you can see I am doing nothing to output a
namespace:
<xsl:template match="title[parent::refDictEntry]">
  <title>
    <xsl:choose>
      <xsl:when test="string-length(substring-before(normalize-space(.),'
'))=0">
        <xsl:apply-templates/> <!-- no word space found so assume only one
word in title -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="substring-before(normalize-space(.),' ')"/> <!--
get first word in title -->
      </xsl:otherwise>
    </xsl:choose>
  </title>
</xsl:template>



  Here's a snippet of output with no namespace on the refDictEntryCjollection
root element:
<?xml version="1.0" encoding="UTF-8"?>
<refDictEntryCollection eid="n1ewuqnosopv1kn1vx2dx8l3rchi" xml:lang="en">
   <refDictEntry eid="p0xkrj83an7dknn1sgukpmnphcje"
                 type="function"
                 xml:lang="en"
                 docAlias="lefunctionsref">
      <?myURI
http://support.sas.com/documentation/cdl/en/lefunctionsref/1/HTML/default/vie
wer.htm#p0xkrj83an7dknn1sgukpmnphcje.htm?>
      <title>ABS</title>
      <shortDescription>Returns the absolute value.</shortDescription>
      <summary>
         <category>Mathematical</category>
      </summary>
      <syntax eid="p07w43trquf74on1ct3ur17des7e">
         <syntaxSimple eid="p005cpxu5su0dkn1b6to129kl254">
            <syntaxLevel>
               <keyword>


  Here's the same snippet when I put the namespace on the root element. Notice
the title, shortDescription, summary and syntax elements now have null
namespaces.
<?xml version="1.0" encoding="UTF-8"?>
<refDictEntryCollection
xmlns="http://www.sas.com/xml/namespace/sas_doc_xis_refDictEntryCollection-1.
0"
                        eid="n1ewuqnosopv1kn1vx2dx8l3rchi"
                        xml:lang="en">
   <refDictEntry eid="p0xkrj83an7dknn1sgukpmnphcje"
                 type="function"
                 xml:lang="en"
                 docAlias="lefunctionsref">
      <?myURI
http://support.sas.com/documentation/cdl/en/lefunctionsref/1/HTML/default/vie
wer.htm#p0xkrj83an7dknn1sgukpmnphcje.htm?>
      <title xmlns="">ABS</title>
      <shortDescription xmlns="">Returns the absolute
value.</shortDescription>
      <summary xmlns="">
         <category>Mathematical</category>
      </summary>
      <syntax xmlns="" eid="p07w43trquf74on1ct3ur17des7e">
         <syntaxSimple eid="p005cpxu5su0dkn1b6to129kl254">
            <syntaxLevel>
               <keyword>


  And finally here's the title element defined in the schema:
       <xs:element name="title">
              <xs:complexType mixed="true">
                     <xs:choice minOccurs="0" maxOccurs="unbounded">
                           <xs:element ref="statValue"/>
                           <xs:element ref="subscript"/>
                           <xs:element ref="superscript"/>
                           <xs:element ref="userSuppliedValue"/>
                           <xs:element ref="windowName"/>
                     </xs:choice>
              </xs:complexType>
       </xs:element>

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.