Jump to content

XSLT filtering


ymeyaw
 Share

Recommended Posts

i have one of the attributes in xml where it is too long to put into table. I wish to do some filtering before convert t o HTML:<attribute name="address">28 thomson road,poscode=75500</attribute>which part of my code (below) should be modified in order to select only the poscode value instead of the whole string?<xsl:value-of select="attribute[@name=address]"/>looking forward for u help..thanks :)

Link to comment
Share on other sites

I would suggest redesigning the element:

<address>  <building>28</building>  <road>Thomson Road</road>  <postcode>75500</postcode></address>

Instead of using this as an attribute, you can then make it a sub-element of you main element:

<objectelement>    <data1>    <data2>    <data3>    <address>       <building>28</building>       <road>Thomson Road</road>       <postcode>75500</postcode>    </address></objectelement>

This will make it easier to navigate the address.Usually attributes are saved for things like id or colour (although these can also be treated as elements), because these are more likely to be used as attributes by HTML - that's how I think of it anyway.In theory, you don't have to have any attributes at all!!Dooberry.

Link to comment
Share on other sites

hi,The output is not under my control as it is system generated. But anyway, thanks for ur advise. I already know how to do that by using:<xsl:value-of select="substring-after(attribute[@name=address],'poscode=')"/>Anway, once again..thanks :)

I would suggest redesigning the element:
<address>  <building>28</building>  <road>Thomson Road</road>  <postcode>75500</postcode></address>

Instead of using this as an attribute, you can then make it a sub-element of you main element:

<objectelement>    <data1>    <data2>    <data3>    <address>       <building>28</building>       <road>Thomson Road</road>       <postcode>75500</postcode>    </address></objectelement>

This will make it easier to navigate the address.Usually attributes are saved for things like id or colour (although these can also be treated as elements), because these are more likely to be used as attributes by HTML - that's how I think of it anyway.In theory, you don't have to have any attributes at all!!Dooberry.

Link to comment
Share on other sites

hi,The output is not under my control as it is system generated. But anyway, thanks for ur advise. I already know how to do that by using:<xsl:value-of select="substring-after(attribute[@name=address],'poscode=')"/>Anway, once again..thanks :)

I would suggest redesigning the element:
<address>  <building>28</building>  <road>Thomson Road</road>  <postcode>75500</postcode></address>

Instead of using this as an attribute, you can then make it a sub-element of you main element:

<objectelement>    <data1>    <data2>    <data3>    <address>       <building>28</building>       <road>Thomson Road</road>       <postcode>75500</postcode>    </address></objectelement>

This will make it easier to navigate the address.Usually attributes are saved for things like id or colour (although these can also be treated as elements), because these are more likely to be used as attributes by HTML - that's how I think of it anyway.In theory, you don't have to have any attributes at all!!Dooberry.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...