[XSLT] template unique pour 2 utilisations différentes
Salut !
Voila mon problème... J'ai un objet défini par la dtd suivante :
Code:
1 2 3 4 5
|
<!ELEMENT object (object-id, object-type, source-info, comment) >
<!ELEMENT object-id (#PCDATA) >
<!ELEMENT object-type (#PCDATA) >
<!ELEMENT source-info (#PCDATA) > |
Cet objet intervient dans une importation et dans une exportation
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<imports>
<source-id>the_import_source_id</source-id>
<source-ref>the_source_ref</source-ref>
<standards-ref>the_standard_ref</standards-ref>
<imported-objects>
<object>
<object-id>the_object_id</object-id>
<object-type>the_object_type</object-type>
<source-info>the_source_info</source-info>
<comment>the comment....</comment>
</object>
...
</imported-objects>
</imports>
<exports>
<source-id>the_export_source_id</source-id>
<source-ref>the_source_ref</source-ref>
<standards-ref>the_standard_ref</standards-ref>
<exported-objects>
<object>
<object-id>the_object_id</object-id>
<object-type>the_object_type</object-type>
<source-info>the_source_info</source-info>
<comment>the comment....</comment>
</object>
...
</exported-objects>
</exports> |
Dans ma feuille de style XSL, j'ai fait comme suit :
Pour l'import :
Code:
1 2 3 4 5 6
|
<xsl:template match="imported-objects">
$ImportedObjects
<xsl:apply-templates select="object"/>
$End_ImportedObjects
</xsl:template> |
Pour l'export :
Code:
1 2 3 4 5 6 7 8
|
<xsl:template match="test-suite-exports">
$Begin_TestSuiteExports
$ExportedObjects
<xsl:apply-templates select="object"/>
$End_ExportedObjects
$End_TestSuiteExports
</xsl:template> |
Et l'objet :
Code:
1 2 3 4 5 6 7
|
<xsl:template match="object">
$ObjectId <xsl:value-of select="object-id"/>
$ObjectType <xsl:value-of select="object-type"/>
$SourceInfo <xsl:value-of select="source-info"/>
$Comment <xsl:value-of select="comment"/>
</xsl:template> |
Or, je vourdrais, que lorsque mon objet est importé, il y ait $ImportedObject au début et $End_ImportedObject à la fin de celui-ci. De même avec $ExportedObject et $End_ExportedObject lorsque celui-ci est exporté... Comment puis-je faire ?
Voici un exemple de résultat :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
$ImportedObjects
$ImportedObject
$ObjectId i
$ObjectType INTEGER
$SourceInfo NO_SOURCE
$Comment /* COMMENT1 */
$End_ImportedObject
$ImportedObject
$ObjectId k
$ObjectType INTEGER
$SourceInfo NO_SOURCE
$Comment /* COMMENT2 */
$End_ImportedObject
$End_ImportedObjects
//
$ExportedObjects
$ExportedObject
$ObjectId i
$ObjectType INTEGER
$SourceInfo NO_SOURCE
$Comment /* COMMENT1 */
$End_ExportedObject
$ExportedObject
$ObjectId k
$ObjectType INTEGER
$SourceInfo NO_SOURCE
$Comment /* COMMENT2 */
$End_ExportedObject
$End_ExportedObjects |
Merki !
+++
Ju