Hello,
I have a XML document that uses references, this is a section of the file just to give the idea
Code:
<?xml version="1.0" encoding="UTF-8"?>
<doc:iso_10303_28 xmlns:exp="urn:oid:1.0.10303.28.2.1.1" xmlns:doc="urn:oid:1.0.10303.28.2.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oid:1.0.10303.28.2.1.1 ex.xsd" version="2.0">
<exp:uos id="uos_1" description="" configuration="default" edo="">
<Document id="i172">
<Id>DOC40</Id>
<Revision>-</Revision>
<Description>LUBRICAT</Description>
<Eco>
<Effectivity id="i173">
<Effdate></Effdate>
<Changenum></Changenum>
</Effectivity>
</Eco>
<Oda>81349</Oda>
<Org></Org>
</Document>
<Document id="i174">
<Id>DOC41</Id>
<Revision>S1</Revision>
<Description>INSTALLA</Description>
<Eco>
<Effectivity id="i175">
<Effdate></Effdate>
<Changenum></Changenum>
</Effectivity>
</Eco>
<Oda>07482</Oda>
<Org></Org>
</Document>
<Part id="i169">
<Id>PART39</Id>
<Marking>Serial Number</Marking>
<Vse>Not Required</Vse>
<Description>BASE</Description>
<Eco>
<Effectivity id="i170">
<Effdate>2010-06-07 16:36:16.0</Effdate>
<Changenum>949703</Changenum>
</Effectivity>
</Eco>
<Oda>07482</Oda>
<Org>G3</Org>
<Applicable_documents id="i171" exp:cType="set">
<Document xsi:nil="true" ref="i172"/>
<Document xsi:nil="true" ref="i174"/>
</Applicable_documents>
</Part>
<Part id="i10992">
<Id>PART3943</Id>
<Marking>None</Marking>
<Vse>Not Required</Vse>
<Description>PIN</Description>
<Eco>
<Effectivity id="i10993">
<Effdate></Effdate>
<Changenum></Changenum>
</Effectivity>
</Eco>
<Oda></Oda>
<Org></Org>
</Part>
<Part id="i10994">
<Id>PART3944</Id>
<Marking>None</Marking>
<Vse>Not Required</Vse>
<Description>BOLT</Description>
<Eco>
<Effectivity id="i10995">
<Effdate></Effdate>
<Changenum></Changenum>
</Effectivity>
</Eco>
<Oda>96906</Oda>
<Org>W1</Org>
</Part>
<Assembly id="i11069">
<Part>
<Part xsi:nil="true" ref="i169"/>
</Part>
<Id>PART39</Id>
<Find>0010C</Find>
<Quantity>0</Quantity>
<Usage>X</Usage>
<Level>0</Level>
</Assembly>
<Ge_part210 id="i15621">
<Document_list id="i15623" exp:cType="set">
<Document xsi:nil="true" ref="i172"/>
<Document xsi:nil="true" ref="i174"/>
</Document_list>
<Part_list id="i15622" exp:cType="set">
<Part xsi:nil="true" ref="i10992"/>
<Part xsi:nil="true" ref="i10994"/>
</Part_list>
<Part_structure id="i15624" exp:cType="set">
<Assembly xsi:nil="true" ref="i11069"/>
</Part_structure>
</Ge_part210>
</exp:uos>
</doc:iso_10303_28>
I want read Ge_part210/Document_list/Document get its ref and then search for a Document with a matching ref. The chosen element must the Document element and not the referenced Document within the Part/Applicable_documents node.
so I have the following
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
xmlns:err="http://www.w3.org/2005/xqt-errors"
exclude-result-prefixes="xs xdt err fn">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Ge_part210">
<xsl:element name="GE_PART210">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Document_list">
<xsl:element name="document-list">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Document">
<xsl:call-template name="get_document">
<xsl:with-param name="ref" select="@ref" />
</xsl:call-template>
</xsl:template>
<xsl:template name="get_document">
<xsl:param name="ref"/>
<xsl:if test="id = @ref" >
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
I'm getting this
Code:
<?xml version="1.0" encoding="UTF-8"?>
PART3943
None
Not Required
PIN
PART3944
None
Not Required
BOLT
96906
W1
PART39
0010C
0
X
0
<GE_PART210>
<document-list>
</document-list>
</GE_PART210>
what am I missing here,am I using the param and if correctly?
cheers,
Ehsan