Jump to content

Recommended Posts

Hello.

 

Trying to make an application that reads an XML document and an XSL document for use in PHP. Right now I can't get the document styled correctly. My xsl:value-of isn't working right now. I have only just begun learning about this kind of thing and don't understand why the value isn't being pulled through.

 

Don't know exactly what question to ask (other than the obvious "what's wrong? why is it not working?"), so if you need more info, fire away and maybe we can hash this out.

 

Thanks.

 

XSL:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />

<xsl:template match="/Report/Group">
<xsl:for-each select="Group">
<xsl:for-each select="Details">
	<xsl:for-each select="Section">
		<xsl:value-of select="Field[Name='ADDRESS']/Value" />
	</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

 

VERY SMALL amount of sample XML:

<?xml version="1.0" encoding="UTF-8" ?>
<Report>
<Group Level="1">
<Group Level="2">
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F1</FormattedValue><Value>F1</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M1</FormattedValue><Value>M1</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L1</FormattedValue><Value>L1</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F2</FormattedValue><Value>F2</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M2</FormattedValue><Value>M2</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L2</FormattedValue><Value>L2</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
</Group>
<Group Level="2">
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F3</FormattedValue><Value>F3</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M3</FormattedValue><Value>M3</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L3</FormattedValue><Value>L3</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F4</FormattedValue><Value>F4</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M4</FormattedValue><Value>M4</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L4</FormattedValue><Value>L4</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
</Group>
<Group Level="2">
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F5</FormattedValue><Value>F5</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M5</FormattedValue><Value>M5</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L5</FormattedValue><Value>L5</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
<Details Level="3">
<Section SectionNumber="0">
<Field Name="FIRSTNAME"><FormattedValue>F6</FormattedValue><Value>F6</Value></Field>
<Field Name="MIDDLENAME"><FormattedValue>M6</FormattedValue><Value>M6</Value></Field>
<Field Name="LASTNAME"><FormattedValue>L6</FormattedValue><Value>L6</Value></Field>
<Field Name="ADDRESSLINE"><FormattedValue>123 Street</FormattedValue><Value>123 Street</Value></Field>
<Field Name="ADDRESSCITY"><FormattedValue>Atlanta</FormattedValue><Value>Atlanta</Value></Field>
<Field Name="ADDRESSSTATE"><FormattedValue>GA</FormattedValue><Value>GA</Value></Field>
<Field Name="ADDRESSZIP"><FormattedValue>30313</FormattedValue><Value>30313</Value></Field>
<Field Name="EMAIL"><FormattedValue>foo@example.tld</FormattedValue><Value>foo@example.tld</Value></Field>
<Field Name="PHONE"><FormattedValue>(555)555- 5555</FormattedValue><Value>(555)555- 5555</Value></Field>
</Section>
</Details>
</Group>
</Group>
</Report>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.