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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
chris dSubject: xslt issue
Author: chris d
Date: 12 Sep 2005 06:34 AM
hi

i'm using this stylesheet


<?xml version='1.0' encoding='us-ascii' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<identities>
<users>
<user>
<xsl:attribute name="firstname">
<xsl:value-of select="users/user/firstname"/>
</xsl:attribute>
<xsl:attribute name="id">
<xsl:value-of select="users/user/@id"/>
</xsl:attribute>
<xsl:attribute name="lastname">
<xsl:value-of select="users/user/lastname"/>
<level>
<xsl:attribute name="name">
<xsl:value-of select="users/user/level_x0020_name"/>
</xsl:attribute>
</level>
<xsl:for-each select="users/user">
<age>
<xsl:attribute name="range">
<xsl:value-of select="age_x0020_range"/>
</xsl:attribute>
</age>
</xsl:for-each>
</user>
</users>
</identities>

</xsl:template>
</xsl:stylesheet>

and what i want it each element /attribute to appear as in the following example file

<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE identities SYSTEM "identifiertransfer-v101.dtd">
<identities version="001" editdate="20050727" customer-id="Magna" completedata="TRUE">
<users>
<user id="94101" firstname="Serge" lastname="Buchner" ><level name="UPP"/><age range="AUT"/></user>

<user id="94102" firstname="Igor" lastname="Smart" ><level name="UPP"/><age range="AUT"/></user>

</users>


</identities>

but it is only displaying one full record and not each of them within the <user> tag. how do i achieve this ?

cheers

chris

Postnext
Tony LavinioSubject: xslt issue
Author: Tony Lavinio
Date: 12 Sep 2005 09:52 AM
You've only wrapped the age within the xsl:for-each, so that's
the only part that's getting executed in the loop.

Try moving the xsl:for-each to between the <users> and <user> line,
and the /xsl:for-each between <user> and <users>.

If that doesn't help, please post your source XML document, so we
can see what the incoming data looks like.

And to post, instead of putting the files in-line, there is a little
checkbox above the reply called "Attach File" which makes extracting
the files to look at simpler.

Postnext
chris dSubject: xslt issue
Author: chris d
Date: 15 Sep 2005 10:54 AM
thanks i worked it out in terms of elements and attributes but i want the converted xml document to contain the doctype declaration at the top of the document - i thought that CDATA would do the trick as below but it doesn't


code:
--------------------------------------------------------------------------------

<![CDATA[ <!DOCTYPE mecidentities SYSTEM "identifiertransfer-v101.dtd"> ]]>

--------------------------------------------------------------------------------



is there something wrong with the cdata ? can i use this for the document type delcaration ?

I also want specify the chracter set in the converted document - would i use the same as above or an xslt function ?

cheers

chris

Postnext
Alberto MassariSubject: xslt issue
Author: Alberto Massari
Date: 15 Sep 2005 03:08 PM
Hi Chris,
in order to generate a DOCTYPE declaration in the output, you need to write

<xsl:output method="xml" doctype-system="identifiertransfer-v101.dtd"/>


Hope this helps,
Alberto

Postnext
chris dSubject: xslt issue
Author: chris d
Date: 16 Sep 2005 05:13 AM
ta

Posttop
Tony LavinioSubject: xslt issue
Author: Tony Lavinio
Date: 16 Sep 2005 02:30 PM
... and you can also set the encoding for the output document in
the xsl:output encoding= attribute.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.