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
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 12 Apr 2007 08:07 AM
Sorry for this simple request--

Postnext
(Deleted User) Subject: Repeating Text
Author: (Deleted User)
Date: 13 Apr 2007 03:55 AM
Hi Mike,
this looks like a grouping operation; you can find several examples in this forum.

Alberto

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 13 Apr 2007 08:51 AM
Ive been trying with your suggestion regarding Grouping and have been trying with the following:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://tempuri.org/XMLSchema.xsd">
<xsl:key name="rows" match="ns1:Root/ns1:Try/ns1:Row" use="Release_Title" />
<xsl:template match="/">
<document>
<xsl:apply-templates select="ns1:Try/ns1:Row/ns1:Release_Title[generate-id(.) = generate-id(key('rows',Release_Title)[1])]"/>
<xsl:for-each select="ns1:Root/ns1:Try/ns1:Row">
<release>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Release_Title"/>
</xsl:attribute>
<xsl:attribute name="catalogNumber">
<xsl:value-of select="ns1:CAT_"/>
</xsl:attribute>
<xsl:attribute name="releaseDate">
<xsl:value-of select="ns1:YYYY_MM_DD"/>
</xsl:attribute>
<track-list>
<track>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Track_Name"/>
</xsl:attribute>
<xsl:attribute name="isrc">
<xsl:value-of select="ns1:ISRC__"/>
</xsl:attribute>
<xsl:attribute name="composer">
<xsl:value-of select="ns1:Composer"/>
</xsl:attribute>
</track>
</track-list>
</release>
</xsl:for-each>
</document>
</xsl:template>
</xsl:stylesheet>



But i cant seem to get the track data for the release with the same Release_Title into the repeating track attribute in the output xml... Im still only getting a single output per release....

Postnext
(Deleted User) Subject: Repeating Text
Author: (Deleted User)
Date: 13 Apr 2007 10:12 AM
Hi Mike,
you are missing some namespace prefixes, and the second loop to create the master-slave relationship. With a few changes, this works (be aware that the 'Sound of Hope' album will not be processed as the second occurrence has an extra whitespace at the end of the title):

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://tempuri.org/XMLSchema.xsd">
<xsl:key name="rows" match="ns1:Row" use="ns1:Release_Title"/>
<xsl:template match="/">
<document>
<xsl:for-each select="ns1:Root/ns1:Try/ns1:Row[generate-id(.) = generate-id(key('rows',ns1:Release_Title)[1])]">
<release>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Release_Title"/>
</xsl:attribute>
<xsl:attribute name="catalogNumber">
<xsl:value-of select="ns1:CAT_"/>
</xsl:attribute>
<xsl:attribute name="releaseDate">
<xsl:value-of select="ns1:YYYY_MM_DD"/>
</xsl:attribute>
<track-list>
<xsl:for-each select="/ns1:Root/ns1:Try/ns1:Row[ns1:Release_Title=current()/ns1:Release_Title]">
<track>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Track_Name"/>
</xsl:attribute>
<xsl:attribute name="isrc">
<xsl:value-of select="ns1:ISRC__"/>
</xsl:attribute>
<xsl:attribute name="composer">
<xsl:value-of select="ns1:Composer"/>
</xsl:attribute>
</track>
</xsl:for-each>
</track-list>
</release>
</xsl:for-each>
</document>
</xsl:template>
</xsl:stylesheet>

Alberto

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 13 Apr 2007 10:30 AM
Alberto-
Honestly, thank you very very much for all of your patience with me and for the fantastic solutions and service that you and Stylus provide-

Warmest Regards,
Mike

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 17 Apr 2007 07:01 AM
Alberto-

If i wanted to rename the output files from "Backcatalog1", "Backcatalog2" etc...:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://tempuri.org/XMLSchema.xsd">
<xsl:key name="rows" match="ns1:Row" use="ns1:Release_Title"/>
<xsl:variable name="outputdir" select="'file:///c:/temp'"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="ns1:Root/ns1:Cat/ns1:Row[generate-id(.) = generate-id(key('rows',ns1:Release_Title)[1])]">
<xsl:result-document href="{$outputdir}/Backcatalog{position()}.xml" method="xml">
<document>
<release>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Release_Title"/> </xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select="ns1:Label"/> </xsl:attribute>
</release>
</document>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


To the text of the current "Label" that was being worked processed, how would i rephrase my wording of the xsl result document?
<xsl:result-document href="{$outputdir}/Backcatalog{position()}.xml" method="xml">

Something like <xsl:result-document href="{$outputdir}/@label{position()}.xml" method="xml"> ??

Postnext
(Deleted User) Subject: Repeating Text
Author: (Deleted User)
Date: 17 Apr 2007 07:05 AM
Hi Mike,
every time you need to evaluate some XPath code inside a literal attribute value, you need to place it inside curly braces (e.g. like you do for position() ). So, just replace @label with {@label}

Hope this helps,
Alberto

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 17 Apr 2007 07:08 AM
Alberto-

If i wanted to rename the output files from "Backcatalog1", "Backcatalog2" etc...:

<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://tempuri.org/XMLSchema.xsd">
<xsl:key name="rows" match="ns1:Row" use="ns1:Release_Title"/>
<xsl:variable name="outputdir" select="'file:///c:/temp'"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="ns1:Root/ns1:Cat/ns1:Row[generate-id(.) = generate-id(key('rows',ns1:Release_Title)[1])]">
<xsl:result-document href="{$outputdir}/Backcatalog{position()}.xml" method="xml">
<document>
<release>
<xsl:attribute name="title">
<xsl:value-of select="ns1:Release_Title"/> </xsl:attribute>
<xsl:attribute name="label">
<xsl:value-of select="ns1:Label"/> </xsl:attribute>
</release>
</document>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


To the text of the current "Label" that was being worked processed, how would i rephrase my wording of the xsl result document?
<xsl:result-document href="{$outputdir}/Backcatalog{position()}.xml" method="xml">

Something like <xsl:result-document href="{$outputdir}/@label{position()}.xml" method="xml"> ??

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 17 Apr 2007 07:09 AM
Thanx!

Postnext
Mike SappSubject: Repeating Text
Author: Mike Sapp
Date: 17 Apr 2007 10:34 AM
Hi Alberto-

I have been using this:
<xsl:result-document href="{$outputdir}/{ns1:Label}_{ns1:Release_Title}_{position()}.xml" method="xml">

however im getting errors everytime there is a '/' in the text of one of the Release Titles.... How would i have the '/' in the text overlooked so that it wouldnt mess up the process and think that it was putting the output to a different directory?

Thank you for your help in advance!

M

Posttop
(Deleted User) Subject: Repeating Text
Author: (Deleted User)
Date: 18 Apr 2007 05:27 AM
Hi Mike,
you can remove unwanted characters from the data by using the 'translate' function, like in {translate(ns1:Release_Title, '/:[]', '____')} where the second argument should list all the characters that are not allowed in a file name, and the third one contains the replacement characters (in this case, it's always the same). If you just want to strip them, remove the third argument.

Hope this helps,
Alberto

 
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.