Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: using For each witin xslt

From: "Anthony Jones" <Ant@------------.--->
To: NULL
Date: 3/1/2007 9:46:00 AM


"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>
>
>




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent