OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] How to extract name of XML file


If you are using XInclude, the root element of each included file should 
have its own xml:base attribute inserted by the XInclude parser, and that 
value identifies the included filename, as a path relative to the file that 
included it.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Nelson, Dean" <dean.nelson@eecradar.com>
To: "Bob Stayton" <bobs@sagehill.net>; <tom_schr@web.de>; 
<docbook-apps@lists.oasis-open.org>
Sent: Thursday, January 11, 2007 1:32 PM
Subject: RE: [docbook-apps] How to extract name of XML file


Bob,
Yes that could work, but I only really have one line because the XML
files use Xinclude to include a tree of other files and therein lies my
problem.

Dean Nelson
Sr. Software Engineer
Enterprise Electronics Corp
http://www.EECradar.com

"Obstacles are those frightful things you see when you take your eyes
off your goal." - Henry Ford


This e-mail, including attachments, may include confidential and/or
proprietary information, and may be used only by the person or entity to
which it is addressed.  If the reader of this e-mail is not the intended
recipient or his or her authorized agent, the reader is hereby notified
that any dissemination, distribution or copying of this e-mail is
prohibited.  If you have received this e-mail in error, please notify
the sender by replying to this  message and delete this e-mail
immediately.




-----Original Message-----
From: Bob Stayton [mailto:bobs@sagehill.net]
Sent: Thursday, January 11, 2007 3:22 PM
To: Nelson, Dean; tom_schr@web.de; docbook-apps@lists.oasis-open.org
Subject: Re: [docbook-apps] How to extract name of XML file


Hi Dean,
The name of the input XML file is not available to an XSLT processor.
After all, the input could be coming from a stream instead of a file.
The
HTML stylesheet inserts the output filename in the TOC, not the input
filename.

I think the simplest way to handle this is to add a stylesheet parameter

named something like 'input.file' and set that on the same command line
that processes your file.  Then you can use the parameter value in the
stylesheet as needed.

Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net


----- Original Message ----- 
From: "Nelson, Dean" <dean.nelson@eecradar.com>
To: <tom_schr@web.de>; <docbook-apps@lists.oasis-open.org>
Sent: Thursday, January 11, 2007 1:09 PM
Subject: RE: [docbook-apps] How to extract name of XML file


Tom

That is similar to what I need, except that I do not want to have to
insert the filename into each file. I have A LOT of files and sections
and the filenames and what sections they Xinclude are still in flux.

However, just for fun I stuck the xml:base in and it extracted SOME of
the filenames. This is a start, but I wonder what happened to the other?
It looks like they disappeared when the second level sction was
encountered in a file.

I am assuming there is a way to do this, as the HTML stylesheets insert
the filename#id in the TOC. If I have to dig at them, then I must. But
compared to all of the XSL brains on this list, I am but a single celled
organism ;-)

I am SLOWLY learning all of the XSL stuff but I was hoping that I had
just missed a line in the documentation that said how to do this.

I am including the whole template here for better context.


Dean Nelson

--------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

    <!-- Clear all other text templates -->
    <xsl:template match="text()"/>

    <!-- Main ADP template -->
    <xsl:template match="book">
    <assistantconfig version="3.2.0">
        <profile>
            <property name="name">EdgeUserManual</property>
            <property name="title">EDGE 5 User Manual</property>
            <property
name="applicationicon">./images/eeclogoletter.gif</property>
            <property name="startpage">html/index.html</property>
            <property name="aboutmenutext">About EDGE 5</property>
            <property name="abouturl">html/e5man.html</property>
            <property
name="assistantdocs">/usr/local/qt/doc/html/</property>
        </profile>
           <DCF ref="html/index.html" icon="images/eeclogo.png"
title="EDGE 5 User Manual">
               <section ref="html/{@xml:base}.html" title="{title}" >
<xsl:text>
               </xsl:text>
                   <xsl:apply-templates/>
               </section> <xsl:text>
               </xsl:text>
           </DCF>
    </assistantconfig>
    </xsl:template>

    <!-- Select top level items -->
          <xsl:template match="section | chapter | appendix | part">
        <section ref="html/{@xml:base}.html" title="{title}" >
<xsl:text>
        </xsl:text>
        <xsl:apply-templates/>
        </section> <xsl:text>
        </xsl:text>
          </xsl:template>

    <!-- Select children -->
    <xsl:template match="section//section">
        <section ref="html/{@xml:base}.html" title="{child::title} "
/><xsl:text>
        </xsl:text>
        <xsl:apply-templates/>
    </xsl:template>
</xsl:stylesheet>






-----Original Message-----
From: tom_schr@web.de [mailto:tom_schr@web.de]
Sent: Thursday, January 11, 2007 2:22 PM
To: docbook-apps@lists.oasis-open.org
Subject: Re: [docbook-apps] How to extract name of XML file


Hi Dean,

On Thursday 11 January 2007 21:04, Nelson, Dean wrote:
>
> One of my tasks is to connect the Docbook HTML files to our
> documentation system that uses QT Assistant.
>
> I have written a short stylesheet that does this - almost. Here is the

> path that I took: 1. search each section for the ID and title in the
> XML file 2. format the output in the simple XML ADP style.
>
> I used the ID as my base of my filename which worked for 90% of the
> info. However, some of IDs did not correspond to a file because they
> were included as subsections in the XML file.

In general, there is no function available in XSLT that can extract the
filename of the corresponding XML file. However, there are other
"tricks" how you can solve your problem.


> Here is what I used:
>
>           <xsl:template match="section | chapter | appendix | part">
> ----->  <section ref="html/{@id}.html" title="{title}" > <xsl:text>
>
>         </xsl:text>
>         <xsl:apply-templates/>
>         </section> <xsl:text>
>         </xsl:text>
>           </xsl:template>

I hope I understood your problem, so please correct me if I am on a
complete wrong track. :) I don't know which DocBook version do you use,
but 4.3 and above provides the xml:base attribute. I use this
occasionally to insert the XML filename. I am not sure if this is the
real intention but it works. :)


> What I want the marked line to say is some thing like this: <section
> ref="html/{Name_Of_XML_File}#{@id}" title="{title}" > [...]

You could insert the xml:base in your DocBook file, for example:

  <sect1 xml:base="foo.xml" ...>

With XSLT you can extract this:

 <section ref="html/{@xml:base}#{@id}" title="{title}" >

However, you have to make sure that the xml:base attribute and the
filename always stay the same, otherwise it won't work.

It's just a crazy idea, I don't know if it is what you was searching
for.


Best wishes,
Tom


-- 
Thomas Schraitle

---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org


---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org









[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]