XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Sebastian FeeseSubject: xsl:element - qname
Author: Sebastian Feese
Date: 14 Nov 2006 08:51 AM
HI,

could anybody of you please tell me what I am doing wrong.
I want to create an xml file from a txt file, where the new elements should all have a different name.

But when I use <xsl:element> the way I do I get the follwoing error:
XSL transformation failed - Expected QName.

Thx for your help!
Sebastian.


<xsl:output method="xml"/>
<xsl:variable name="in" select="string('dump.txt')"/>

<xsl:template match="/">
<xsl:variable name="line" select="tokenize(unparsed-text($in), '\r?\n')"/>



<xsl:for-each select="$line">
<xsl:variable name="pos" select="position()"/>
<xsl:if test="contains(current(),'PCB')">
<xsl:variable name="header-fields" select='tokenize(normalize-space(current())," ")'/>
<xsl:variable name="nextLine" select="$line[ $pos +1 ]"/>
<xsl:variable name="nextLine-fields" select="tokenize(normalize-space($nextLine),' ')"/>


<xsl:for-each select="$header-fields">
<xsl:variable name="pos" select="position()"/>
<xsl:variable name="name" select="."/>
<xsl:element name="{$name}">
<xsl:value-of select="$nextLine-fields[$pos]"/>
</xsl:element>

</xsl:for-each>
</xsl:if>
</xsl:for-each>

</xsl:template>

Postnext
Tony LavinioSubject: xsl:element - qname
Author: Tony Lavinio
Date: 14 Nov 2006 08:56 AM
Use the debugger to find out exactly what the value of {$name} is,
to make sure you have selected what you think you have selected.

Posttop
James DurningSubject: xsl:element - qname
Author: James Durning
Date: 14 Nov 2006 11:35 AM
Originally Posted: 14 Nov 2006 11:34 AM
If you have 2 spaces in a row, tokenize will give you an empty string. Eg. if you tokenized "ab c d" (2 spaces between c and d, this forum truncates), you'd get "ab", "c", "", "d"


You may need to add a check that the name does not equal the empty string "".

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.