[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
Re: [xsl] Chunking xml into single-topic docs
Subject: Re: [xsl] Chunking xml into single-topic docs From: JBryant@xxxxxxxxx Date: Thu, 24 Feb 2005 11:25:18 -0600 |
Hi, Marcy, Assuming you can have numbers in your file names, you could use <xsl:count> to number the files, resulting in Product1, Product2, and so on. Of course, you'll need an if or a choose to handle names that have a count of 1, unless you are OK with all file names having a number. I would be more inclined to use the entire title as the name of the file, perhaps replacing spaces with underscores if need be. That can lead to some long file names, such as "Operating_the_Deteronic_Frombotzer_in_Sub-zero_Temperatures.xml", but maybe that wouldn't be a problem for your file system. The advantage of it is that you can determine the file's content without opening it. You can also do some neat scripting with something like Perl to create a table of contents from a directory listing. This kind of naming can be a big help for programmatic document assembly, so long as you are strict about your naming convention. As an aside from your actual question, I notice that you have a lot of not() functions at one point. I haven't seen the XML, so I don't know what's possible, but it seems that it would be more maintainable if you could find an actual match rather than finding something that doesn't match a lot of other things. I'm curious what you plan to do with the single-topic blocks. Will they appear as the content of a help system? Having disassembled a document, will you use the blocks to construct both the original document and other documents? Both help and documents? I am a combination of technical writer and programmer (the kind of technical writer who actually is technical), so I have a good idea of what you are doing. I have abandoned FrameMaker and have taken up writing entirely in XML (I have customized a text editor for the purpose), using XSL to generate my output. I often re-purpose content, swiping bits from two documents to assemble a new document. XSL is great for this kind of thing. Good luck with your project and welcome to the XSL community. Jay Bryant Bryant Communication Services (presently consulting at Synergistic Solution Technologies) "Kessler, Marcy" <marcy.kessler@xxxxxx> 02/24/2005 11:01 AM Please respond to xsl-list@xxxxxxxxxxxxxxxxxxxxxx To <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> cc Subject [xsl] Chunking xml into single-topic docs I'm taking documents that are authored in FrameMaker, converting them into structured xml files and then using an XSLT to transform them into DTD compliant single-topic xml documents. The problem I'm having is that the single-topic files that are created take the first word of the heading of each section and that is the file name for the xml file. However, if the first word is the same in more than one heading (i.e. Product Overview, and Product Specifications) the first file is overwritten by the second occurrence and the first file isn't created. As a newbie (frantically trying to learn xsl, Xpath, etc. as quickly as possible), I'm struggling with knowing where to start in fixing the problem. I was hoping any of you could point me in the right direction. Any help would be much appreciated. Thanks - Marcy Here is a section of the common.xsl file that I think needs to be changed: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" escape-uri-attributes="no" omit-xml-declaration="no" encoding="UTF-8" indent="yes" doctype-system="c:/Conversion/Tool/dtds/c_support_doc.dtd"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <xsl:apply-templates select="NoName"/> </xsl:template> <xsl:variable name="chap.title" select="//ChapTitle"/> <xsl:template match="NoName"> <xsl:for-each-group select="*[not(following-sibling::ChTOC1) and not(following-sibling::ChTOC2) and not(self::ChTOC2) and not(self::ChTOC1) and not(following-sibling::ChapTOC1) and not(following-sibling::ChapTOC2) and not(self::ChapTOC2) and not(self::ChapTOC1) and not(self::TableAnchor[not(child::*)]) and not(self::ChapNum) and not(self::ChapTitle) and not(self::Cross-Ref)]" group-starting-with="OneHead"> <xsl:variable name="file_title"> <xsl:value-of select="translate(normalize-space(.),' ','_')"/> </xsl:variable> <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> <xsl:variable name="title3"> <xsl:value-of select="translate($file_title,'_',' ')"/> </xsl:variable> <xsl:result-document href="{$title2}"> <c_support_doc> <title> <xsl:value-of select="$title3"/> </title> <short.title> <xsl:value-of select="$title3"/> </short.title> <generic> <section> <xsl:call-template name="addId"/> <xsl:if test="current-group()[1][self::Note]"> <para> <note> <para> <xsl:value-of select="current-group()[self::Note][1]"/> </para> </note> </para> </xsl:if> <xsl:if test="current-group()[1][self::BodyText]"> <para> <xsl:value-of select="current-group()[self::BodyText][1]"/> </para> </xsl:if> <xsl:if test="current-group()[1][self::Body]"> <para> <xsl:value-of select="current-group()[self::Body][1]"/> </para> </xsl:if> <xsl:apply-templates select="current-group()[self::OneHead]" /> <xsl:for-each-group select="current-group() except ." group-starting-with="TwoHead"> <xsl:choose> <xsl:when test="self::TwoHead"> <section> <xsl:call-template name="addId"/> <xsl:apply-templates select="current-group()[self::TwoHead]"/> <xsl:for-each-group select="current-group() except ." group-starting-with="ThreeHead"> <xsl:choose> <xsl:when test="self::ThreeHead"> <section> <xsl:call-template name="addId"/> <xsl:apply-templates select="current-group()[self::*]"/> </section> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()[self::*]"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </section> </xsl:when> <xsl:otherwise> <xsl:for-each-group select="current-group()" group-starting-with="ThreeHead"> <xsl:choose> <xsl:when test="self::ThreeHead"> <section> <xsl:call-template name="addId"/> <xsl:apply-templates select="current-group()[self::*]"/> </section> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="current-group()[self::*]"/> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </xsl:otherwise> </xsl:choose> </xsl:for-each-group> </section> </generic> </c_support_doc> </xsl:result-document> </xsl:for-each-group> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Chunking xml into single-, David Carlisle | Thread | RE: [xsl] Chunking xml into single-, Michael Kay |
Re: [xsl] Chunking xml into single-, David Carlisle | Date | [xsl] Using attributes and elements, António Mota |
Month |