Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: using For each witin xslt >Thread Next - Re: using For each witin xslt Re: using For each witin xsltTo: NULL Date: 3/3/2007 2:09:00 PM
OK, I appogise as I have been struggling.....Your right I do not need a For
each. I thought that I would.
Below is my xslt code
<xslt:if test="@CName = 'Win32_NetworkAdapter'">
<IPAddress>
<xslt:value-of
select="Property[@PName='IPAddress:Win32_NetworkAdapterConfiguration']/@Value"
/>
</IPAddress>
</xslt:if>
My result in my xml file is as follows:
<IPAddress>N/A</IPAddress>
<IPAddress>N/A</IPAddress>
<IPAddress>N/A</IPAddress>
<IPAddress>10.176.152.2</IPAddress>
<IPAddress>N/A</IPAddress>
<IPAddress>N/A</IPAddress>
<IPAddress>N/A</IPAddress>
<IPAddress>N/A</IPAddress>
I I have multiple entries and maybe I am using the code you provided wrong.
I know what needs to be done to eliminate the additonal xml tags that are
not IpAddresses.
The below property name when the value is "True" is the only time i should
grab the IPAddress and MAC.(Left MAC field out for simplicity) I know the
field below when true is the adapters information I need and should probably
exist outside the tag <IPAddress>
"IPEnabled:Win32_NetworkAdapterConfiguration"
'''Modified with psuedo code but unsure of how to incorprate into stylesheet
code.
<xslt:if test="@CName = 'Win32_NetworkAdapter'">
'gET the adapter Property value if the device in the enabled
one.(IPEnabled:Win32_NetworkAdapterConfiguration)
<xslt:if test="IPEnabled:Win32_NetworkAdapterConfiguration" = True>
'When true inventory the adapter for IPAddress and MAC, otherwise goto the
next one.
<IPAddress>
<xslt:value-of
select="Property[@PName='IPAddress:Win32_NetworkAdapterConfiguration']/@Value"
/>
</IPAddress>
</xsl:if>
</xslt:if>
Any help is definently appreciated as I did npot think this would be as
difficult.
"Anthony Jones" <Ant@y...> wrote in message
news:eA8Svf$WHHA.4076@T......
>
> "Big D" <BigDaddy@n...> wrote in message
> news:%23CfEmW$WHHA.2212@T......
>> I only put two instances of the Win32_NetworkAdapter but typically see at
>> most 8. Basically I need to interate through all adapters AND
>>
>> IF IPEnabled:Win32_NetworkAdapterConfiguration = True
>> Grab the Ipaddress and Macaddress properties. 'When true that
>> means the adapter is the active one.
>>
>> Else If IPEnabled:Win32_NetworkAdapterConfiguration =False
>> 'Do nothing and move on until there are no adapters.
>> End If
>>
>>
>> Normally any inactive adapter will be false and is not adapter with the
>> IP
>> infomration.
>>
>
> If you are going to do nothing with the adapters where IPEnabled is false
> why to you need to iterate at all. Surely what you are saying is you need
> to select the Class where IPEnabled:Win32_NetworkAdapterConfiguration =
> True
> ??
>
> <xsl:variable name="ActiveNetAdaptor"
> select="Class[Property[@PName='IPEnabled:Win32_NetworkAdapterConfiguration'
> and Value='true']]" />
>
> <xsl:value-of
> select="$ActiveNetAdaptor/Property[@PName='MACAddress"]/@Value" />
> <xsl:value-of
> select="$ActiveNetAdaptorProperty[@PName='IPAddress:Win32_NetworkAdapterConf
> iguration"]/@Value" />
>
>
>
>
>
>>
>> I hope this is clearer.
>>
>> Thanks again for your help!
>> "Anthony Jones" <Ant@y...> wrote in message
>> news:e$WqlZ%23WHHA.996@T......
>> >
>> > "Big D" <BigDaddy@n...> wrote in message
>> > news:uZc4xY6WHHA.996@T......
>> >> I have an xml file and the data in the xml file is WMI information. I
> am
>> >> using a stylesheet(xslt file) to get the data I actually need from
>> >> the
>> > file
>> >> that has all kinds of information. Where I have run into a problem is
>> >> when
>> >> WMI properties is having multipe instances. For example, the
>> >> Win32_NetworkAdapter can have up to eight instances or more. I do not
>> >> want
>> >> to extract all 8 instances of the adapters but rather the only adater
>> >> I
>> > care
>> >> about is the one with the MAC address and IP Aaddress.(Active Adapter)
>> > This
>> >> information can be in any instance of the eight(1-8) and I am not able
> to
>> >> key off of a instance.
>> >>
>> >> How can I within my stylesheet do the logic to look grab the
> information
>> >> needed where the IPAddress and MAC are not null. All other adapters
>> >> are
>> >> Null.
>> >>
>> >> Pseudo code of what i want to acomplish
>> >>
>>
>>> -------------------------------------------------------------------------
> -
>> > ----
>> >> select each Win32_NetworkAdapter instance and where
>> >> "IPEnabled:Win32_NetworkAdapterConfiguration" Value="true" IS TRUE.
>> >>
>> >> IF true Then get the following values within that instance....
>> >>
>> >> IPAddress:Win32_NetworkAdapterConfiguration" Value="10.112.14.5"
>> >> "MACAddress:Win32_NetworkAdapterConfiguration"
> Value="00:90:FB:0B:83:ED"
>>
>>> -------------------------------------------------------------------------
> -
>> > ----
>> >
>> > Hmm your psuedo code does match your text description above. Are you
>> > saying
>> > the criteria for selection is that the class needs to have:-
>> >
>> > 1) IPAddress and MACAddress
>> > OR
>> > 2) IPAddress or MACAddress
>> > OR
>> > 3) only one will be IPEnabled anyway so fetch that one and get the
> values
>> > of IPAddress and MACAddress
>> >
>> > I'll take 3 let me know otherwise.
>> >
>> >>
>> >> <xsl:for-each
>> >>
>> > select="Property[@PName='IPAddress:Win32_NetworkAdapterConfiguration']">
>> >> </xsl:for-each>
>> >
>> > <xsl:for-each
>> >
>> >
> select="Class[Property[@PName=IPEnabled:Win32_NetworkAdapterConfiguration'
>> > and Value='true']]">
>> > </xsl:for-each>
>> >
>> > Given the context is the root node holding the Class elements the above
>> > returns all Class elements that have a property with a PName attribute
>> > =
>> > IPEnabled and a Value attribute = true.
>> >
>> >
>> >>
>> >>
>> >>
>> >> Example, XML file
>> >> <Class CName="Win32_NetworkAdapter" CInstance="0">
>> >> <Property PName="AdapterType" Value="Ethernet 802.3" PInstance="0"
>> > Index="0"
>> >> DType="8"/>
>> >> <Property PName="Description" Value="Intel(R) PRO/100 VM Network
>> > Connection"
>> >> PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="Index" Value="0" PInstance="0" Index="0" DType="19"/>
>> >> <Property PName="Installed" Value="true" PInstance="0" Index="0"
>> >> DType="11"/>
>> >> <Property PName="MACAddress" Value="00:90:FB:0B:83:ED" PInstance="0"
>> >> Index="0" DType="8"/>
>> >> <Property PName="Manufacturer" Value="Intel" PInstance="0" Index="0"
>> >> DType="8"/>
>> >> <Property PName="ServiceName" Value="E100B" PInstance="0" Index="0"
>> >> DType="8"/>
>> >> <Property PName="TimeOfLastReset" Value="02/25/2007 22:44:35"
>> > PInstance="0"
>> >> Index="0" DType="101"/>
>> >> <Property PName="DefaultIPGateway:Win32_NetworkAdapterConfiguration"
>> >> Value="10.112.14.1" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="DHCPEnabled:Win32_NetworkAdapterConfiguration"
>> >> Value="false" PInstance="0" Index="0" DType="11"/>
>> >> <Property PName="DNSHostName:Win32_NetworkAdapterConfiguration"
>> >> Value="VSSRES001403" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="Index:Win32_NetworkAdapterConfiguration" Value="0"
>> >> PInstance="0" Index="0" DType="19"/>
>> >> <Property PName="IPAddress:Win32_NetworkAdapterConfiguration"
>> >> Value="10.112.14.5" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="IPEnabled:Win32_NetworkAdapterConfiguration"
>> >> Value="true"
>> >> PInstance="0" Index="0" DType="11"/>
>> >> <Property PName="IPSubnet:Win32_NetworkAdapterConfiguration"
>> >> Value="255.255.255.0" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="MACAddress:Win32_NetworkAdapterConfiguration"
>> >> Value="00:90:FB:0B:83:ED" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="ServiceName:Win32_NetworkAdapterConfiguration"
>> >> Value="E100B" PInstance="0" Index="0" DType="8"/>
>> >> </Class>
>> >>
>> >> <Class CName="Win32_NetworkAdapter" CInstance="1">
>> >> <Property PName="Description" Value="RAS Async Adapter" PInstance="0"
>> >> Index="0" DType="8"/>
>> >> <Property PName="Index" Value="1" PInstance="0" Index="0" DType="19"/>
>> >> <Property PName="Installed" Value="true" PInstance="0" Index="0"
>> >> DType="11"/>
>> >> <Property PName="TimeOfLastReset" Value="02/25/2007 22:44:35"
>> > PInstance="0"
>> >> Index="0" DType="101"/>
>> >> <Property PName="DefaultIPGateway:Win32_NetworkAdapterConfiguration"
>> >> Value="N/A" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="Description:Win32_NetworkAdapterConfiguration"
>> >> Value="RAS
>> >> Async Adapter" PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="DHCPEnabled:Win32_NetworkAdapterConfiguration"
>> >> Value="false" PInstance="0" Index="0" DType="11"/>
>> >> <Property PName="Index:Win32_NetworkAdapterConfiguration" Value="1"
>> >> PInstance="0" Index="0" DType="19"/>
>> >> <Property PName="IPAddress:Win32_NetworkAdapterConfiguration"
> Value="N/A"
>> >> PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="IPEnabled:Win32_NetworkAdapterConfiguration"
>> > Value="false"
>> >> PInstance="0" Index="0" DType="11"/>
>> >> <Property PName="IPSubnet:Win32_NetworkAdapterConfiguration"
> Value="N/A"
>> >> PInstance="0" Index="0" DType="8"/>
>> >> <Property PName="ServiceName:Win32_NetworkAdapterConfiguration"
>> >> Value="AsyncMac" PInstance="0" Index="0" DType="8"/>
>> >> </Class>
>> >>
>> >>
>> >
>> >
>>
>>
>
>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
