j'ai suivi le thread suivant sur le forum US pour créer mes XSLT d'import/export :
http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=3490
J'ai posté un message concernant mon problème, mais peut-être que vous pourrez m'aider pour le résoudre... Le voici.
Mon fichier d'export XSLT me permet d'exporter correctement mon XML.
- XSLT :
- Code: Tout sélectionner AgrandirRéduire
<?xml version="1.0" encoding="UTF-8"?>
<!-- We must define several namespaces, because we need them to access -->
<!-- the document model of the in-memory OpenOffice.org document. -->
<!-- If we want to access more parts of the document model, we must -->
<!-- add there namesspaces here, too. -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
exclude-result-prefixes="office table text">
<xsl:output method = "xml" indent = "yes" encoding = "UTF-8" omit-xml-declaration = "no"/>
<!-- By setting the PropertyValue "URL" in the properties used in storeToURL(), -->
<!-- we can pass a single parameter to this stylesheet. -->
<!-- Caveat: If we use the "URL" property in the stylesheet and call in OOo -->
<!-- from the menu "File" > "Export...", OOo assigns a target URL. And that -->
<!-- might not be what we want. -->
<xsl:param name="targetURL"/>
<!-- Process the document model -->
<xsl:template match="/">
<p:rulesLibary xmlns:p="http:///my_address/resources/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:///my_address/resources/rules.xsd rules.xsd " >
<!-- Process all tables -->
<xsl:apply-templates select="//table:table"/>
</p:rulesLibary>
</xsl:template>
<xsl:template match="table:table">
<!-- Process all table-rows after the column labels in table-row 1 -->
<xsl:for-each select="table:table-row">
<xsl:if test="position()>1">
<rule>
<!-- Process the first for columns containing ruleName, ruleArgument, ruleFqn and property -->
<xsl:for-each select="table:table-cell">
<xsl:choose>
<xsl:when test="position()=1">
<ruleFqn><xsl:value-of select="text:p"/></ruleFqn>
</xsl:when>
<xsl:when test="position()=2">
<ruleName><xsl:value-of select="text:p"/></ruleName>
</xsl:when>
<xsl:when test="position()=3">
<ruleArgument><xsl:value-of select="text:p"/></ruleArgument>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</rule>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
- Fichier XML correctement généré:
- Code: Tout sélectionner AgrandirRéduire
<?xml version="1.0" encoding="UTF-8"?>
<p:rulesLibary xmlns:p="http:///my_address/resources/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:///my_address/resources/rules.xsd rules.xsd ">
<rule>
<ruleFqn>aaa</ruleFqn>
<ruleName>bbb</ruleName>
<ruleArgument>ccc</ruleArgument>
</rule>
<rule>
<ruleFqn>ddd</ruleFqn>
<ruleName>eee</ruleName>
<ruleArgument>fff ggg</ruleArgument>
</rule>
</p:rulesLibary>
Le problème, c'est que je ne peux pas ouvrir ce fichier XML en appliquant mon filtre d'import XSLT.
Mon XSLT d'import:
- Code: Tout sélectionner AgrandirRéduire
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" office:version="1.0" >
<office:automatic-styles>
<!-- Column styles (co1: column with 10 cm width, co2: column with 8 cm width) -->
<style:style style:name="co1" style:family="table-column">
<style:table-column-properties fo:break-before="auto" style:column-width="10.000cm"/>
</style:style>
<style:style style:name="co2" style:family="table-column">
<style:table-column-properties fo:break-before="auto" style:column-width="8.000cm"/>
</style:style>
</office:automatic-styles>
<office:body>
<office:spreadsheet>
<table:table>
<!-- Format the first 4 columns of the table -->
<table:table-column table:style-name="co1" table:default-cell-style-name="Default"/>
<table:table-column table:style-name="co2" table:default-cell-style-name="Default"/>
<table:table-column table:style-name="co2" table:default-cell-style-name="Default"/>
<!-- Insert column labels, first label with default style, the remaining 3 labels right aligned -->
<table:table-row>
<table:table-cell><text:p>ruleFqn</text:p></table:table-cell>
<table:table-cell><text:p>ruleName</text:p></table:table-cell>
<table:table-cell><text:p>ruleArgument</text:p></table:table-cell>
</table:table-row>
<!-- Process XML input: Insert one row for each rule -->
<xsl:for-each select="p:rulesLibrary" xmlns:p="http:///my_address/resources/rules.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:///my_address/resources/rules.xsd rules.xsd " >
<xsl:for-each select="rule">
<table:table-row>
<!-- Insert string rule fqn -->
<table:table-cell>
<text:p><xsl:value-of select="ruleFqn"/></text:p>
</table:table-cell>
<!-- Insert string rule name -->
<table:table-cell>
<text:p><xsl:value-of select="ruleName"/></text:p>
</table:table-cell>
<!-- Insert string rule arg -->
<table:table-cell>
<text:p><xsl:value-of select="ruleArgument"/></text:p>
</table:table-cell>
</table:table-row>
</xsl:for-each>
</xsl:for-each>
</table:table>
</office:spreadsheet>
</office:body>
</office:document-content>
</xsl:template>
</xsl:stylesheet>
Voyez-vous ce que j'ai fait de travers?
Merci d'avance,
Nicolas
Le Modérateur a écrit:Merci de ne pas inventer et de respecter la syntaxe des balises : ftopic1369.html
Le balisage doit bien sûr être correctement orthographié (première lettre en majuscule puis le reste en minuscules).




