Using xmlstarlet and OpenOffice
Brian St. Pierre
brian at bstpierre.org
Wed Mar 3 14:08:56 EST 2010
On Wed, Mar 3, 2010 at 12:21 PM, Bruce Dawson <jbd at codemeta.com> wrote:
> [WARNING: Lots of code here...]
Adding the -C option to your command line yields:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exslt="http://exslt.org/common"
xmlns:math="http://exslt.org/math"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:func="http://exslt.org/functions"
xmlns:set="http://exslt.org/sets"
xmlns:str="http://exslt.org/strings"
xmlns:dyn="http://exslt.org/dynamic"
xmlns:saxon="http://icl.com/saxon"
xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
xmlns:xt="http://www.jclark.com/xt"
xmlns:libxslt="http://xmlsoft.org/XSLT/namespace"
xmlns:test="http://xmlsoft.org/XSLT/"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
extension-element-prefixes="exslt math date func set str dyn saxon
xalanredirect xt libxslt test"
exclude-result-prefixes="math str">
<xsl:output omit-xml-declaration="yes" indent="no" method="text"/>
<xsl:param name="inputFile">-</xsl:param>
<xsl:template match="/">
<xsl:call-template name="t1"/>
</xsl:template>
<xsl:template name="t1">
<xsl:value-of select="office:*"/>
</xsl:template>
</xsl:stylesheet>
Note that only the first -N namespace declaration (office=...) is
emitted in the XSLT. This makes me think the doc lies when it says
multiple -N options are supported. Maybe there's a special trick to
make it work?
When I change the XPath expression to only use the office namespace, I
get the following:
$ xmlstarlet select --net -T \
> -N office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" \
> -N style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" \
> -N text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" \
> -N table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" \
> -N draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" \
> -N fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" \
> -N xlink="http://www.w3.org/1999/xlink" \
> -N dc="http://purl.org/dc/elements/1.1/" \
> -N meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" \
> -N number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" \
> -N svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" \
> -N chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" \
> -N dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" \
> -N math="http://www.w3.org/1998/Math/MathML" \
> -N form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" \
> -N script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" \
> -N ooo="http://openoffice.org/2004/office" \
> -N ooow="http://openoffice.org/2004/writer" \
> -N oooc="http://openoffice.org/2004/calc" \
> -N dom="http://www.w3.org/2001/xml-events" \
> -N xforms="http://www.w3.org/2002/xforms" \
> -N xsd="http://www.w3.org/2001/XMLSchema" \
> -N xsi="http://www.w3.org/2001/XMLSchema-instance" \
> -N field="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:field:1.0" \
> -t -v 'office:*' content.xml
Trailer Rental AgreementSomeFarm; 123 Some Road; Town NH
03307603-783-3315I, SomeRenter, hereby agree to use the Keifer Built
horse trailer owned by Some One (owner) for $VerySmallSum/day. Trailer
will be picked up on 1 Jan 2010 and returned on 1 Jan 2010 to qualify
for 0 day(s) rental.I agree that I am responsible for any and all
bodily injury or property damage that may occur while it is in my
possession. Further, I agree to hold the owner absolutely harmless
from any responsibility for any claim whatsoever during the time of my
use.The value of the trailer is hereby agreed to be $2500. I agree to
pay the owner up to $VeryLargeSum for any damage to it. Repair costs
will be determined solely by SomeFarm of Town, NH.The trailer shall
not be moved with other than a 2” ball hitch.The trailer shall not be
moved without its lights in full operation.No one other than the
person signing below will move the trailer.Social Security #
123-45-6789Drivers License # 12ABC000101Copy of Vehicle Registration:
attachedCopy of Certificate of Insurance: attachedCopy of Drivers
License: attachedName/Driver 000 Some Street; SomePlace, NHSignature
___________________________________________Telephone #
603-555-1234Date TodaySignature of SomeFarm
representative__________________________________________________
Unfortunately, I don't have any hints to help you get multiple
namespaces into the XSLT.
-Brian
More information about the gnhlug-discuss
mailing list