to show you of what i'm talking, heres how my archive and
my product tree xml files look like (very abstract):
Right. Excellent idea. I thought last time I asked you why
didn't you post a real XML document that demonstrates your
problem? So you didn't get the hint?
Note that that doesn't parse to: "You should post your real
documents and code". Instead, it parses to: "You should
post smallest possible well-formed, valid documents and
code that demonstrate the problem you want to solve." This
is what is referred to as SSCCE on some newsgroups.
<Common name="..." path="..." />
<Common ... />
<Glue name="..." path="..." />
<Glue ... />
<Mtds name="..." path="..." />
<Mtds ... />
<Mtds ... />
<ARCHIVE>
<Module moduleName="moduleA" variant="2"
subsystem="subsystemA" path="..." textConvention="..." />
<Module moduleName="moduleX" variant="17"
subsystem="subsystemB" path="..." textConvention="..." />
<Product cid="9000" subsystem="subsystemD" path="..."
textConvention="..." />
</ARCHIVE>
Not well-formed in more ways than I care to list.
<PRODUCT_TREE productName="TestProduct"
softwareVersion="1.0" description="...">
<TopLevelComponent topLevelModule="Mab" cid="1200"
description="..."> <Module selectedModule="moduleA"
instance="12"/> <Component topLevelModule="Mxy" cid="9000"
description="..."> <SubComponent topLevelModule="Mxy"
cid="5500" description="..."> <Module
selectedModule="moduleX" instance="1"/> </SubComponent>
</Component>
</TopLevelComponent>
</PRODUCT_TREE>
PRODUCT_TREE/selectedModule
Doesn't make any sense to me. PRODUCT_TREE element doesn't
have any selectedModule element children.
Doesn't make any sense to me. ARCHIVE element doesn't have
any moduleName element children.
[snip requirements]
Please follow the link at the end of this post and read the
document located there. You seem to be under the false
impression that we're here to do your job for you, with no
compensation whatsoever. Can't say about other posters, but
I'm most certainly not.
<xsl:for-each select="TopLevelComponent">
Don't use xsl:for-each unless you understand what it is and
how it works.
<xsl:for-each select="document($archive)">
Gr-r-reat idea.
<xsl:copy-of select="cid($cid)/*"/>
Excellent indentation. Looks great when wrapped to 78
characters. if you don't want help, why don't you just say
so?
Oh, and there's no cid() function in XPath.
<
http://www.catb.org/~esr/faqs/smart-questions.html>
NB: You're this >< short of being *plonk*ed.
Wooooow, cool down Pavel! I don't want you to do my job - I just need
help doing it myself!
Okay, maybe I didn't get the hint with the SSCCE but that should not
give you a reason to ... Forget it.
I just don't understand why helped me in such a great way before and
now you talk to me like I'm a stupid kid not knowing that it is
dangerous to walk across the street while the signal's red! But I will
learn from this and I will try make my questioning better. But I must
admit that I feel a little patronized right now. Wasn't I thankful
enough or what is the problem? I just didn't post my complete XML
files before, because I feared being accused of letting you do my job!
And it just happend anyway...
I didn't mean it bad. Of course not!
So, okay. I just beg your pardon and try to get back to the topic.
Here are my files (as you would call it SSCCEE):
----- archive.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<PMBv2>
<ARCHIVE>
<Common path="D:/common/common_1.tmp" name="common_1"/>
<Common path="D:/common/common_2.tmp" name="common_2"/>
<Common path="D:/common/common_3.tmp" name="common_3"/>
<Glue path="D:/glue/glue_1.tmp" name="glue_1"/>
<Glue path="D:/glue/glue_2.tmp" name="glue_2"/>
<Mtds path="D:/mtds/mtds_1.tmp" name="mtds_1"/>
<Mtds path="D:/mtds/mtds_2.tmp" name="mtds_2"/>
<Mtds path="D:/mtds/mtds_3.tmp" name="mtds_3"/>
<Mtds path="D:/mtds/mtds_4.tmp" name="mtds_4"/>
<Mtds path="D:/mtds/mtds_5.tmp" name="mtds_5"/>
<Mtds path="D:/mtds/mtds_6.tmp" name="mtds_6"/>
<Mtds path="D:/mtds/mtds_7.tmp" name="mtds_7"/>
<Mtds path="D:/mtds/mtds_8.tmp" name="mtds_8"/>
<Mtds path="D:/mtds/mtds_9.tmp" name="mtds_9"/>
<Module path="D:/module-specific/module_mt_m1235_3_{MNCL}{MNCN}
{MNMI}.tmp" mid="m1235" moduleName="MODULE-MT-M1235-3-TMP" variant="3"
tokens="{MNCL}{MNCN}{MNMI}" tc="D:/module_tc/module_mt_m1235_tc.tmp"/>
<Module path="D:/module-specific/module_mt_m1237_2_subsystemA_{MNCL}
{MNCN}{MNMI}.tmp" mid="m1237" moduleName="MODULE-MT-M1237-2-SUBSYSTEMA-
TMP" variant="2" subsystem="subsystemA" tokens="{MNCL}{MNCN}{MNMI}"
tc="D:/module_tc/module_mt_m1237_tc.tmp"/>
<Product path="D:/product-specifc/product_mt_product_9000_{MNCL}
{MNCN}{MNMI}.tmp" cid="5500" moduleName="PRODUCT-MT-PRODUCT-9000-MIB"
tokens="{MNCL}{MNCN}{MNMI}"/>
<Product path="D:/product-specifc/
product_mt_product_5500_subsystemX_{MNCL}{MNCN}{MNMI}.tmp" cid="5500"
moduleName="PRODUCT-MT-PRODUCT-5500-SUBSYSTEMX-MIB"
subsystem="subsystemX" tokens="{MNCL}{MNCN}{MNMI}" tc="D:/module_tc/
product_mt_product_5500_tc.tmp"/>
</ARCHIVE>
</PMBv2>
----- prodtree.xml -----
<?xml version="1.0" encoding="UTF-8"?>
<PMBv2 xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="D:\PMBv2\install
\pmbv2_prodtree_schema.xsd">
<PRODUCT_TREE productName="MyProduct" description="Text"
softwareVersion="2.0">
<TopLevelComponent topLevelModule="M14" cid="1700"
description="Text">
<Module selectedModule="MODULE-MT-M1235-3-MIB" instance="23"
description="Text"/>
<Component topLevelModule="M16" cid="1300" description="Component
description.">
<Module instance="12" description="Text" selectedModule="MODULE-MT-
M1236-2-TMP"/>
<SubComponent topLevelModule="M16" cid="5500" description="Text">
<Module instance="10" description="Text" selectedModule="MODULE-
MT-M1235-3-TMP"/>
</SubComponent>
<SubComponent topLevelModule="M14" cid="1300" description="Text">
<Module instance="17" description="Text" selectedModule="MODULE-
MT-M1235-4-TMP"/>
<SubComponent topLevelModule="M9" cid="9000" description="Text">
<Module instance="12" description="Text" selectedModule="MODULE-
MT-M1235-3-TMP"/>
</SubComponent>
</SubComponent>
</Component>
</TopLevelComponent>
</PRODUCT_TREE>
</PMBv2>
So, what I want to do now - ME, not you! But of course I need your
help - is the following:
- copy all <Common>, <Glue> and <Mtds> nodes to prodtree.xml
For each node in prodtree.xml check if
- there is a <Product> in archive.xml with the same cid attribute.
-->if so: append all attributes (that would then be: path, subsystem,
moduleName and tokens) to my <*Component> node in prodtree.xml
- there is a <Module> in archive.xml where the moduleName attribute
has the same value as my current selectedModule attribute
--> if so: append all attributes (that would then be: path, mid,
variant, tokens, tc and subsystem) to the my <Module> node in
prodtree.xml
BTW: I know that the code I posted before made no sense - but believe
it or not, thats a copy&paste from a small tutorial I found while
googleing... So I just gave it a shot! Thats how I learn... Trial and
error until I get it working. Stop *plonk*ing me for that.
Another BTW: I already signed up for a XSLT workshop in January. I
just mentioned that to avoid further charges.