[xslt] Executing xslt scripts



I would like to be able to execute xsltfiles directly.  For instance,
given the file:
        
        #!/usr/bin/xsltproc
        <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
          <xsl:template match="node()|@*">
            <xsl:copy>
              <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
          </xsl:template>
        </xsl:stylesheet>

I would like to be able to run

    ./tt.xslt < in.xml > out.xml

and have everything just work.

Right now xsltproc *almost* does this except the xslt parser complains
of the shebang line.  Were xsltproc to skip the first line of an xslt
script if it begins with a "#!" then this would work beautifully.


I looked in the source but didn't see an easy way to get the parser to
skip the first line.  If someone could give me a hint on the best way to
do this, I'd be happy to wring together a patch.


Why I want this:

- It makes chaining xslt pipelines easier:

   cat myfile | ./transform1 | ./transform2 > out.xml


- It makes filters much easier to specify in programs.  Right now, to
specifyiing xslt filters in liferea is a drag.  You need to type
"xsltproc ~/transform.xslt -" -- a 3 arguments.  If tt.xslt were an
executable file, then you could specify it as you do any other filter,
with a standard file dialog.  That's much easier!


- It would make my life nicer to not have to have to write shell script
to automate simple transforms.


Thanks,

    - Scott








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]