|
Hi Thanks for the info...still no joy (and I am trying - have been all ****** afternoon...)
Overall reqs are - use select tab from front end. I extract just the nodes which have the tab attribute set to this tab. So a) I need to be able to pass the tab name down from the front end into the xsl and b) use it in teh xsl. I am still struggling with b) and not even looked at a) yet!!
My code now, with your changes, still gives the exception....I need a little more hand holding. This is my first venture into XSL and really struggling, both conceptually, and syntactically.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="tabName">
<xsl:text>Main</xsl:text>
</xsl:variable> <xsl:template match="Fields">
<table border="3">
<xsl:copy>
<xsl:apply-templates select="BatchParam">
<xsl:sort select='@tab'/>
<xsl:sort select='@seq'/>
</xsl:apply-templates>
</xsl:copy>
</table>
</xsl:template>
<xsl:template match="BatchParam[@tab=$tabName]"> <tr>
<td><xsl:value-of select='position()'/></td>
<td><xsl:value-of select='@tab'/></td>
<td><xsl:value-of select='@name'/></td>
<td><xsl:value-of select='@seq'/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
It still doesn't like the $tabName. VS2005 highlights it as a problem in the editor before i run it!
Regards
AngelMalc
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Ok, there are a few changes that you have to make to your XSL:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="tabName"><xsl:text>Tab 2</xsl:text></xsl:variable>
<xsl:template match="Fields">
<table border="3">
<xsl:apply-templates select="BatchParam[@tab=$tabName]">
<xsl:sort select="@Seq" data-type="number"/>
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="BatchParam">
<tr>
<td><xsl:value-of select='position()'/></td>
<td><xsl:value-of select='@tab'/></td>
<td><xsl:value-of select='@name'/></td>
<td><xsl:value-of select='@Seq'/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
The first change is for the value of tabName from "Main" to "Tab 2" so it actually matches something in the XML you provided. The next thing is the statement BatchParam[@tab=$tabName] . Normally you can do this, but the problem is where you placed it. You put it in the select for the template match. You simply can't put variables there. You want that variable to be placed in the call to the template match, not in the declaration of the template match. Also, your select of @seq wasn't returning anything because the XML you provided was using Seq as the attribute. So be careful of the case sensitivity. Also, be sure to specify the "number" data type when sorting otherwise you can get something like 1, 10, 11, 12, 2, 3, etc.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hero. Many thanks. The 'Main' bit was a typo, the code I pasted wasn't the code I am working on (not allowed....).
I appreciate your help, and looking at the number of posts on here, a lot of others appreciate your help as well!!
Regards
Malc
*********************************************
|
|
|
|
|
And for completeness, I swapped the xsl:variable for a xsl:param and in the code used XsltArgumentsList to populate it from the client - and it works a treat.
Thanks again
Regards
Malc
*********************************************
|
|
|
|
|
Awesome. Glad to hear everything's working out. Although I am starting to feel like an XSL/XPath *cough*expert*cough*. Not sure if that's a good thing.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hello There
can any one mail me or post me a link for complete reference on Xpath ?
rbashir@alm-soft.com
|
|
|
|
|
|
Consider this xml:
<br />
<rrx id="someother">...</rrx><br />
<rrx id="Zones"><br />
<f name="NM"><br />
<p name="xoxoxo"/><br />
</f><br />
<s name="GB"><br />
<p name="xexexe"/><br />
<p name="xaxaxa"/><br />
</s><br />
<a name="SP"><br />
<p name="hmhmhm"/><br />
</a><br />
<b name="Alien"><br />
<p name="opsops"/><br />
</b><br />
</rrx><br />
I need to select all "p" elements in "f","s" or "a" with a given "name" but not "b" which are in "rrx" with particular "id". So I'm trying to come up with or statement for f,s,a in the middle of XPath.
Using XSLT 2.0 and Xpath 2.0 this works fine:
//rrx[@id='Zones']/(f|s|a)[@name='GB']/p - I should get xexexe and xaxaxa and if
//rrx[@id='Zones']/(f|s|a)[@name='SP']/p - I need hmhmhm
But good old 1.0 says it's invalid. That () are not allowed there. How else would the XPath then look?
|
|
|
|
|
The feature you try to use is new to XPath 2.0
One of the ways you could solve it in XPath 1.0 would be:
instead of:
//rrx[@id='Zones']/(f|s|a)[@name='SP']/p
write:
//p[(parent::f[(@name='SP')and(parent::rrx[@id='Zones'])]) or (parent::s[(@name='SP')and(parent::rrx[@id='Zones'])]) or (parent::a)[(@name='SP')and(parent::rrx[@id='Zones'])]]
It does not look nice, but would be an example.
|
|
|
|
|
Hi all,
how would i set the page width in xsl to 80mm?
i want to create a template for a slip printer....
He who laughs last...
|
|
|
|
|
Okay thanks anyways, i'll just use a table and set it according.
Sorry, i thought of it a i posted the message.
He who laughs last...
|
|
|
|
|
Sorry, the table idea didn't work. is it possible to set the page width, because if i try to print now, through the slip printer, it prints it fine but i keeps spitting out paper... my friend suggested that it could be because the xsl is using an A4 and the slip is only 80mm in width, actually 79.5mm, and it is not working correctly because of this...
Please help
He who laughs last...
|
|
|
|
|
The simple-page-master node has an available page-width property.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Excuse me for this quick noob question.
Let's say I have XML:
<br />
<a name="a1">text</a><br />
<a>text 2</a><br />
<a name="a3">text 3</a><br />
What's the XPath syntax to locate that secon "a" element that doen't have the "name" attribute?
-- modified at 12:42 Tuesday 1st August, 2006
|
|
|
|
|
Try this: a[not(boolean(@name))]
That will give you everything that doesn't have a name attribute.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Oh, that's great! Thanks a lot! Works!
|
|
|
|
|
Using "≤" the representation of "less or equal to sign" in an XML Doc gives an error. Any correct way to handle this?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
In what context are you using this symbol? Is it just somewhere in the XML text? Are you using it in an XPath? Are you doing a transformation? What kind of error are you getting? Does it not display correctly? Does it not transform?
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Thanks for the response. I am using it in the XML text. Currently, I used "<=", which displays as <=. But have seen ≤ used in MSDN.
Due to the XML Doc errors, the comment is ignored and never displayed.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
Oh, I see. You meant code documentation. Ya, you have to use a CDATA tag for that. I use the character map tool in windows and paste it in there.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Thanks for the support. I am back to work and will be trying it today. Frankly, I have never thought of using the CDATA in XML Doc! or may be I forgot it is XML!!!
Have a nice day/night and God bless you.
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
For some reason when I am parsing the xml from a stream using XMLTextReader I am unable to use the elements with Underscores in their names. Does anybody know why this is? Here is the code I am using:
'encapsulate the string to fool xmlreader
Dim strReader As StringReader = New StringReader(strXMLStream)
'Create the XML Reader
Dim m_xmlr As XmlTextReader = New XmlTextReader(strReader)
'Disable whitespace so that you don't have to read over whitespaces
m_xmlr.WhiteSpaceHandling = WhiteSpaceHandling.NONE
'read the xml declaration and advance to first line after ok
Dim i as integer
For i = 0 to 2
m_xmlr.Read()
Next
m_xmlr.Read()
m_xmlr.Read()
m_xmlr.Read()
Dim firstNameValue = m_xmlr.ReadElementString("AVAILABLE")
Dim exchangeValue = m_xmlr.ReadElementString("EXCHANGE_ID")
This brings an error saying the EXCHANGE_ID element can not be found but it is definately in the XML
James Boag. Genius
|
|
|
|
|
It doesn't have anything to do with the underscore. The XmlTextReader won't discriminate on that. Make sure that the "EXCHANGE_ID" node is directly after the "AVAILABLE" node.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Dear all,
I have a webservice project running on Computer A.
I am calling a webmethod from this web service from an asp.net project on computer B, it is working correctly.
But the problem is when i am trying to call the same webmethod from another asp.net project on the computer B, i am receiving this error:
The underlying connection was closed: Unable to connect to the remote server.
it is not a security problem or configuration since the same webmethod is working on the first asp.net project
Can anyone help, thanks.
|
|
|
|
|
Hi All,
How can I design a GUI for an application using XML and C++(MFC etc)
Any guidelines/links where I can read/study on this.
Thanks in advance
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|