xsl-list
[Top] [All Lists]

Re: Chunking xml into single-topic docs

2005-02-24 10:42:08
Marcy,

The trouble you are having is resulting from this bit of code:

At 12:01 PM 2/24/2005, you wrote:
                <xsl:variable name="title">
                <xsl:choose>
                  <xsl:when test="contains($file_title,'_')">
                    <xsl:value-of
select="escape-uri(substring-before($file_title,'_'),true())"/>
                   </xsl:when>
                  <xsl:otherwise>
             <xsl:value-of select="escape-uri($file_title,true())"/>
                  </xsl:otherwise>
                </xsl:choose>
                </xsl:variable>

                <xsl:variable name="title2">
                <xsl:choose>
                  <xsl:when test="contains($title,' ')">

                <xsl:value-of select="substring-before($title,' ')"/>
                        <xsl:text>.xml</xsl:text>
                  </xsl:when>
                  <xsl:when test="contains($title,'/')">

                <xsl:value-of select="substring-before($title,'/')"/>
                        <xsl:text>.xml</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="$title"/>
                        <xsl:text>.xml</xsl:text>
                  </xsl:otherwise>
                </xsl:choose>
                </xsl:variable>

This is what implements the logic you have described. Since the declaration of $file_title has already converted new-lines into '_', these variable declarations serve basically to trim the name further, ultimately taking whatever string is available up to '_' or ' ' as a code to use for the filename.

The logic is implemented well enough, but of course it's faulty given the requirement, for the reason you outline: files stepping on each other because names are not unique. So you need some other way of generating a unique code for each file.

This is a very open-ended requirement, and only you decide what kind of code would serve. Any ideas? If you were to ask the list what we have done in analogous situations, I'm sure there would be many answers. In particular, the questions come up of whether you need the file names to be transparent, and how long you are willing to let them get. (It's not hard to make them unique and either short or transparent, but generally harder to do all of these together.) Note that until a functional specification is clear, this isn't really an XSLT question. :->

I hope this helps,
Wendell




___&&__&_&___&_&__&&&__&_&__&__&&____&&_&___&__&_&&_____&__&__&&_____&_&&_
    "Thus I make my own use of the telegraph, without consulting
     the directors, like the sparrows, which I perceive use it
extensively for a perch." -- Thoreau

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--