0

Hello, first post here so take it easy :)

I have been searching with no luck on finding a solution - hopefully you can help!

I need to reference a xml file and get the value of an element. In my initial xml post, I will send along an ip address, this ip address will be set as a variable in my xsl transform. I need to use that variable to be used to reference the element on the xml document.

sample xml (IP to Alias lookup):

<servers>
	<ip id="172.22.17.79">
		<server>myServer1</server>
	</ip>
	<ip id="172.22.17.80">
		<server>myServer2</server>
	</ip>
	<ip id="172.22.17.81">
		<server>myServer3</server>
	</ip>
</servers>

xsl transform

<!--this is the variable set from my xml post -->
<xsl:variable name="server1ip" select="/config/server1ip"/>  
<!-- this is the variable that references the servers.xml doc -->
<xsl:variable name="server1ipLU" select="document('servers.xml')"/>
<!--this is the select I am having issues with - I need it to return the server value value -->
<xsl:value-of select="$server1ipLU/servers[@ip=$server1ip]/server"/>

Let me know if you need more information, I appreciate the help!

-David

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by hielo
0

@ip=$server1ip

ip is a node, NOT an attribute.

for testing purposes try: select="document('servers.xml')/servers/ip[@id='172.22.17.80']"

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.