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 August 18th, 2006, 10:21 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with XSLT: xmi:type="{@xmi:type}" (plz help)


In the sample below, the code xmi:type="{@xmi:type}" always generates the error "javax.xml.transform.TransformerException: Prefix must resolve to a namespace: xmi"
How can i solve this (how can i get the value of a attribute named "@xmi:type") ?

(name="{@name}" works fine, the only problem is the xmi:type="{@xmi:type}")

Plz help, i really need this :-p

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml" encoding="UTF-8"/>
    <xsl:template match="ownedMember">
        <ownedMember name="{@name}" xmi:type="{@xmi:type}"/>
    </xsl:template>
</xsl:stylesheet>
 
Old August 18th, 2006, 10:49 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You need to declare the namespace in your stylesheet, e.g.

xmlns:xmi="http://some.namespace.uri/"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old August 18th, 2006, 11:18 AM
Registered User
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ty very much Mr. Michael Kay, now it works! (xmlns:xmi="http://schema.omg.org/spec/XMI/2.1")

However, plz help me with this colateral effect:

Using the code:
<xsl:template match="ownedMember">
   <ownedMember name="{@name}" xmi:type="{@xmi:type}"/>
</xsl:template>

I am getting the result:
<ownedMember xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmi:type="uml:DataType" name="String"/>

Well, i dont want the "xmlns:xmi" attribute to be coppied to any <ownedMember> tag it generates. The proper result would be <ownedMember xmi:type="uml:DataType" name="String"/>

Any way to fix this?

Ty again!


 
Old August 18th, 2006, 11:23 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

If your output has an attribute named xmi:type, then it must declare the xmi namespace, otherwise it wouldn't be valid XML output.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Guidelines Item 3: Replace System.Type with Type Ixtlia BOOK: Professional .NET 2.0 Generics 0 August 19th, 2007 04:09 AM
Element value type in XSLT 1.0 NEO1976 XSLT 9 February 13th, 2007 11:11 AM
Convert "String" type to "Control" type ? kishore_peddi C# 4 January 11th, 2006 01:21 PM





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