Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 9th, 2007, 05:42 AM
Authorized User
 
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Creating xsi:type as an attribute

I am using XSL to create elements and attributes

Its not permitting me to create an attribute called
xsi:type as an attribute to an element.

Code:
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:fix="http://www.fixprotocol.org/FIXML-4-4" 
xmlns:i="http://www.ABC.com/interests:i" 
xmlns:strategies="http://www.ABC.com/strategies" 
xmlns:common="http://www.ABC.com/equity.derivatives/common"
exclude-result-prefixes="fo"> 

..

<xsl:element name="i:Details">
<xsl:attribute name="xsi:type">
<xsl:text>i:details.stock</xsl:text>
</xsl:attribute>
How can I create xsi:type as an attribute to element i:Details
so that the output looks like:

Code:
i:Details xsi:type="i:details.stock">

Am I overlooking something? I am new to using xsi:type




 
Old May 9th, 2007, 09:14 AM
Authorized User
 
Join Date: Apr 2007
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe I'm completely off here, but when you use a namespace like xsi, don't you have to declare it first?

xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"

 
Old May 9th, 2007, 10:23 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Actually, in xsl:attribute, there are two ways of indicating the namespace. You can use

<xsl:attribute name="foo:bar"/>

in which case foo must have been declared, or you can use

<xsl:attribute name="foo:bar" namespace="uri"/>

in which case foo does not need to have been declared, since the namespace URI is taken from the namespace attribute, and not from the namespace binding of foo.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 9th, 2007, 01:46 PM
Authorized User
 
Join Date: Apr 2007
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So would he need this?
Code:
<xsl:attribute name="xsi:type" namespace="http://www.w3.org/1999/XMLSchema-instance">
  <xsl:text>i:details.stock</xsl:text>
</xsl:attribute>
 
Old May 9th, 2007, 02:15 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Either of the following should do:

 So would he need this?

<xsl:attribute name="xsi:type" namespace="http://www.w3.org/1999/XMLSchema-instance">
  <xsl:text>i:details.stock</xsl:text>
</xsl:attribute>

<xsl:attribute name="xsi:type" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
  <xsl:text>i:details.stock</xsl:text>
</xsl:attribute>

(I thought I had answered this, but I must have made the usual mistake of replying to the email notification...)


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 10th, 2007, 09:49 AM
Authorized User
 
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot folks
I have solved this issue
Thans,once again






Similar Threads
Thread Thread Starter Forum Replies Last Post
exclude-result-prefixes="#all" and xsi:type maxtoroq XSLT 2 November 7th, 2008 08:46 PM
problem with xsi:SchemaLocation akshay144 XML 2 August 20th, 2008 05:40 AM
Creating a "Frame" type page bruceaj CSS Cascading Style Sheets 7 April 16th, 2007 01:34 AM
after creating chart -> type mismatch error kritimehrotra Excel VBA 2 July 19th, 2006 01:58 PM
copy-of xsi namespace chris_strub XSLT 2 October 2nd, 2004 10:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.