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

RE: missing xsi: before schemaLocation in the result x

Subject: RE: missing xsi: before schemaLocation in the result xml file.
From: "Lin, Jessica" <jlin@xxxxxxxxxxx>
Date: Thu, 12 Oct 2006 15:39:22 -0700
schemalocation attribute missing on import
I didn't use <xsl:apply-templates select="*"/> in my xslt file. I tried
to run the simplified xml and xslt files but I still got the same
result. Here are my simplied xml and xslt files. Could you please take a
look at them?


<blueprint xmlns="http://directv.com/bitstreams/blueprint"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://directv.com/bitstreams/blueprint
..\xsd\Blueprint.xsd" base_time="2004-11-05T12:00:00"
duration_seconds="12" tail_seconds=".25" version="1.00">
   <apg>
     <boot_object key="bo1">
	  <boot_object_header>
		<object_type>0</object_type>
		<object_version>0</object_version>
		<reserved>65535</reserved>
	      <time_first_referenced>compute</time_first_referenced>
		<object_id>1</object_id>
	  </boot_object_header>
	  <boot_object_body>
		<root_category_system_object_id ref="cso1"/>
<secondary_boot_cycle_time>4</secondary_boot_cycle_time>
		<secondary_boot_SCID>2049</secondary_boot_SCID>
<reserved1>255</reserved1>
		<reserved2>15</reserved2>
	   </boot_object_body>
	</boot_object>
   </apg>
</blueprint>


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0 "
xmlns="http://directv.com/bitstreams/blueprint"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
exclude-result-prefixes="xs xdt">

<xsl:import href="copy.xslt" />

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="*:boot_object">
  <advanced_boot_object>
	<xsl:copy-of select="@*"/>
	<xsl:apply-templates/>
	<xsl:apply-templates select="boot_object_header"/>

  </advanced_boot_object>
</xsl:template>

<xsl:template match="*:boot_object_header">
   <advanced_boot_object_header>
	<object_type>153</object_type>
	<xsl:apply-templates select="node()[not(self::*:object_type)]"
/>
	</advanced_boot_object_header>
</xsl:template>
</xsl:stylesheet>

-----Original Message-----
From: Abel Braaksma [mailto:abel.online@xxxxxxxxx]
Sent: Thursday, October 12, 2006 2:50 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  missing xsl: before schemaLocation in the result xml
file.

Lin, Jessica wrote:
> I am converting xml to xml by using xslt. For some reason, my result
> missed "xsl:" before schemaLocation. Could you please help me find
> what's wrong?
>
> [...]
> And I use imported file copy.xslt during procession.
>
> <xsl:template match="/ | node() | @* | comment() |
> processing-instruction()">
>   <xsl:copy>
>     <xsl:apply-templates select="@* | node()"/>
>   </xsl:copy>
> </xsl:template>
>
>
> My result xml file:
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns:bp="http://directv.com/bitstreams/blueprint"
>            xmlns="http://directv.com/bitstreams/blueprint"
>
> [...]
>            schemaLocation="http://directv.com/bitstreams/blueprint
> [...]
>

You use an extended version of the copy idiom. It should copy all
elements including namespaces correctly. I tried your XML
file,.simplified the XSLT like the following and it outputs the 'xsi'
(I'm sure you meant 'xsi', not 'xsl') in front of the schemaLocation
attribute.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
    <xsl:output indent="yes" />
    <xsl:template match="/ | node() | @* | comment() |
        processing-instruction()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>


Though technically it is possible that the prefix changes, it seems not
the case in your example. The namespace actually changes. Since you say
that you <xls:import /> the copy xslt file, the problem may lay in your
main file. If there's any instruction at all, any template at all, it
will supersede the copy xslt. This is due to import precedence rules
(copy.xslt is imported and has as such a lower precedence) and the fact
that most specific rules always come first. Thus, if your main xslt file

looks something like this (I hope not):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"
    xpath-default-namespace="http://directv.com/bitstreams/blueprint">
    <xsl:import href="copy.xslt" />
    <xsl:output indent="yes" />
    <xsl:template match="/*">
        <xsl:copy>
            <xsl:apply-templates select="*"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

your output will be off on the root node. But you must do something
different than that, because you actually change the schemaLocation
attribute, or you add it by hand somewhere in your code, without
attaching it to the namespace again. If somewhere you do create it by
hand, you can do the following to attach the namespace:

<xsl:attribute name="xsi:schemaLocation"
namespace="http://www.w3.org/2001/XMLSchema-instance"  />

Though you don't need to specify any prefix here. If you don't the
processor will think one up for you.

Hth,

Cheers,
-- Abel Braaksma
   http://www.nuntia.com

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.