Jump to content

Search the Community

Showing results for tags 'xpath'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 21 results

  1. I'm trying to break a string into an array based on the length. for Ex: If I have a string of 30 characters, I want to convert into an array of 5 characters each using an xpath function. Is there any way to do this? Also, I noticed in this thread - Creating an incremental count variable in XSLT / XPath when using Xpath for..in..return? that we can use "For" as "For $i in 1 to $length return $i". When I'm trying to use "1 to 5" i.e. constants, xpath is accepting, but when I'm trying to pass a variable " 1 to $length", xpath is not accepting. Please suggest ASAP. Alex
  2. Thanks for looking into this issue. I am not sure, whether this is the right forum to post this thread. If not, let me know the right forum to post this thread. I have wellformed XML message. I want to produce a list/report as 1) All Xpath of XML message 2) Xpath , data content for this XPATH Here is an example (Input XML Message) <?xml version="1.0"?><PARTS><TITLE>Computer Parts</TITLE><PART><ITEM>Motherboard</ITEM><MANUFACTURER>ASUS</MANUFACTURER><MODEL>P3B-F</MODEL><COST> 123.00</COST></PART><PART><ITEM>Video Card</ITEM><MANUFACTURER>ATI</MANUFACTURER><MODEL>All-in-Wonder Pro</MODEL><COST> 160.00</COST></PART><PART><ITEM>Sound Card</ITEM><MANUFACTURER>Creative Labs</MANUFACTURER><MODEL>Sound Blaster Live</MODEL><COST> 80.00</COST></PART><PART><ITEM>inch Monitor</ITEM><MANUFACTURER>LG Electronics</MANUFACTURER><MODEL> 995E</MODEL><COST> 290.00</COST></PART></PARTS> The desired output --> I created the following XML list manually /PARTS/TITLE Computer Parts/PARTS/PART[1]/ITEM Motherboard/PARTS/PART[1]/MANUFACTURER ASUS/PARTS/PART[1]/MODEL P3B-F/PARTS/PART[1]/COST 123.00/PARTS/PART[2]/ITEM Video Card/PARTS/PART[2]/MANUFACTURER ATI............................................................... I have XMLSPY, and I do not have additional tools kit associated with XMLSPY. I tried with xml_grep in linux. It need the XPATH as input to get me the data content. I am not able to use xml_grep to extract attributes of XML message. Are there any open source product to produce such report for XML Message? What are the ways to extract XPATHs/XPATH, data content? Thanks for helping.
  3. Anybody that can solve this issue? My question is about =importxml in Google Docs. This editor doesn't allow uploading of my image of question. Please go to http://forum.jquery.com/topic/importxml-and-jquery. I think the grammar is right but doesn't work. Regards,
  4. pbac83

    Xpath query

    Hello, I've the following example xml structure: <news> <new> <newid>3443</newid> <title>Title1</title> <body>Body1 hello everyone</body> <url>/news/tech-3443</url> </new> <new> <newid>3753</newid> <title>Title2</title> <body>Body2 hello everyone</body> <url>/news/social-3753</url> </new> <new> <newid>3113</newid> <title>Title3</title> <body>Body3 hello everyone</body> <url>/news/tech-3113</url> </new> </news> How can write a Xpath query to fetch only nodes with the prefix "/news/tech-" in the "url" field? Many thanks! Piero
  5. Hi guys! I'm having a problem that it's driving me crazy. It must be simple for most of you, but for me it has been a nightmare. Basically, I need to clean up the namespaces in a XML file for a more friendly reading. I am learning to use XSLT for that, but I am not understanding how to apply the correct XPATH sentence in the XSLT. The original XML file looks like that: <?xml version="1.0" encoding="utf-16"?><cResultado xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Servicos xmlns="http://tempuri.org/"> <cServico> <Codigo>40010</Codigo> <PrazoEntrega>1</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro /> <obsFim /> </cServico> <cServico> <Codigo>50020</Codigo> <PrazoEntrega>3</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro>TESTE</MsgErro> <obsFim /> </cServico> </Servicos></cResultado> I would like to transform it on that: <?xml version="1.0" encoding="utf-16"?><cResultado> <Servicos> <cServico> <Codigo>40010</Codigo> <PrazoEntrega>1</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro /> <obsFim /> </cServico> <cServico> <Codigo>50020</Codigo> <PrazoEntrega>3</PrazoEntrega> <EntregaDomiciliar>S</EntregaDomiciliar> <EntregaSabado>S</EntregaSabado> <Erro /> <MsgErro>TESTE</MsgErro> <obsFim /> </cServico> </Servicos></cResultado> I am using this XSLT to produce the desired XML file, but It doesn't work: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" ><xsl:output method="xml" indent="yes"/><xsl:template match="/"> <Servicos> <xsl:for-each select="//*[local-name() = 'cServico']"> <cServico> <Codigo><xsl:value-of select="Codigo"/></Codigo> <PrazoEntrega><xsl:value-of select="PrazoEntrega"/></PrazoEntrega> <EntregaDomiciliar><xsl:value-of select="EntregaDomiciliar"/></EntregaDomiciliar> <EntregaSabado><xsl:value-of select="EntregaSabado"/></EntregaSabado> <Erro><xsl:value-of select="Erro"/></Erro> <MsgErro><xsl:value-of select="MsgErro"/></MsgErro> <obsFim><xsl:value-of select="obsFim"/></obsFim> </cServico> </xsl:for-each> </Servicos> </xsl:template></xsl:stylesheet> Probably I am not using the correct XPATH sentence in the XSLT because of the namespaces. Could you help with that? Thanks, Euler Almeida
  6. I have this html table: <tbody><tr>..</tr><tr><td class="tbl_black_n_1">1</td><td class="tbl_black_n_1" nowrap="" align="center">23/07/14 08:10</td><td class="tbl_black_n_1"><img src="http://www.betonews.com/img/SportId389.gif" width="10" height="10" border="0" alt=""></td><td class="tbl_black_n_1"></td><td class="tbl_black_n_1" nowrap="" align="center">BAK WS</td><td class="tbl_black_n_1" nowrap="" align="right">M. Eguchi</td><td class="tbl_black_n_1" align="center">-</td><td class="tbl_black_n_1" nowrap="">Radwanska U. </td><td class="tbl_black_n_1" align="center" title=" ">1,02</td><td class="tbl_black_n_1" align="center"><td class="tbl_black_n_1" align="center" title=" "> </td><td class="tbl_black_n_1" align="center"><td class="tbl_black_n_1" align="center" title=" ">55,00</td><td class="tbl_black_n_1" align="center"><td class="tbl_black_n_1" align="right">86%</td><td class="tbl_black_n_1" align="right">-</td><td class="tbl_black_n_1" align="right">14%</td><td class="tbl_black_n_1" align="center" title=" ">524.647</td><td class="tbl_black_n_1" nowrap=""><a href="popup.asp?tp=2100&lang=en&idm=553759" target="_blank"><img src="http://www.betonews.com//img/i_betfair.gif" width="12" height="10" border="0" alt=""></a><a href="popup.asp?tp=2110&lang=en&idm=553759" target="_blank"><img src="http://www.betonews.com//img/i_history.gif" width="12" height="10" border="0" alt=""></a></td></tr><tr>..</tr><tr>..</tr><tr>..</tr>...</tbody> There are more than one hundred <tr> structured at the same way, which contain lots of <td>.I manage to loop with xpath to store all data in a database except one: the last <td> element.. i want the href attribute of the first <a>. So, in my example: "popup.asp?tp=2100&lang=en&idm=553759", but when i run my query, id variable retrieve a NULL value. Help!! This is my php code, but I can not go on.. $document = new DOMDocument();$document->loadHTML($response);$xpath = new DOMXPath($document);$expression = '(//table[@cellpadding="3"])[1]/tr[position() > 1]';$rows = $xpath->query($expression);foreach ($rows as $row) { $result = array(); $td = $row->childNodes; $data = $td->item(2)->nodeValue; $immagine = $td->item(4)->firstChild->attributes->getNamedItem("src")->nodeValue; $team1 = $td->item(10)->nodeValue; $team1 = stripText($team1); $team2 = $td->item(14)->nodeValue; $team2 = stripText($team2); $id = $td->item(36)->childNodes->item(1)->attributes->getNamedItem("href")->nodeValue‌​;
  8. It'll be great if you could fill the xmls tutorial with example. Considering how short most of them all. Espically xslt, xquery, xpath, etc.
  9. hello dear all new to this forums and also new to php. so do not bear with me.well i am not too familiar with PHP. We just should run a few more xpath queries inside the loop for all the address keys and the website. we need to do this here <?php/** * OSM Overpass API with PHP SimpleXML / XPath * * PHP Version: 5.4 - Can be back-ported to 5.3 by using 5.3 Array-Syntax (not PHP 5.4's square brackets) *///// 1.) Query an OSM Overpass API Endpoint//$query = 'node ["amenity"~".*"] (38.415938460513274,16.06338500976562,39.52205163048525,17.51220703125);out;';$context = stream_context_create(['http' => [ 'method' => 'POST', 'header' => ['Content-Type: application/x-www-form-urlencoded'], 'content' => 'data=' . urlencode($query),]]);# please do not stress this service, this example is for demonstration purposes only.$endpoint = 'http://overpass-api.de/api/interpreter';libxml_set_streams_context($context);$start = microtime(true);$result = simplexml_load_file($endpoint);printf("Query returned %2$d node(s) and took %1$.5f seconds.nn", microtime(true) - $start, count($result->node));//// 2.) Work with the XML Result//# get all school nodes with xpath$xpath = '//node[tag[@k = "amenity" and @v = "school"]]';$schools = $result->xpath($xpath);printf("%d School(s) found:n", count($schools));foreach ($schools as $index => $school){ # Get the name of the school (if any), again with xpath list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; printf("#%02d: ID:%' -10s [%s,%s] %sn", $index, $school['id'], $school['lat'], $school['lon'], $name);}?> i just have had a quick view on the above mentioned site. i try to figure out how to do this - for any and all hints i am thankful The following code lists all schools and tries to obtain their names as well. I have not covered translations yet because my sample data didn't have those, but you can also look for all kind of names including translations and just prefer a specific one): //// 2.) Work with the XML Result//# get all school nodes with xpath$xpath = '//node[tag[@k = "amenity" and @v = "school"]]';$schools = $result->xpath($xpath);printf("%d School(s) found:n", count($schools));foreach ($schools as $index => $school){ # Get the name of the school (if any), again with xpath list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; printf("#%02d: ID:%' -10s [%s,%s] %sn", $index, $school['id'], $school['lat'], $school['lon'], $name);} The key point here are the xpath queries.In the above mentioend example two are used, the first xpath queriy is to get the nodes that have certain tags.I think this is the most interesting one for me: //node[tag[@k = "amenity" and @v = "school"]] This line says: Give us all node elements that have a tag element inside which has the k attribute value "amenity" and the v attribute value "school". This is the condition we have to filter out those nodes that are tagged with amenity school.Further on xpath is used again, now relative to those school nodes to see if there is a name and if so to fetch it: tag[@k = "name"]/@v' This line says: Relative to the current node, give me the v attribute from a tag element that as the k attribute value "name". As you can see, some parts are again similar to the line before. I think you can both adopt them to your needs.Because not all school nodes have a name, a default string is provided for display purposes by adding it to the (then empty) result array: list($name) = $school->xpath('tag[@k = "name"]/@v') + ['(unnamed)']; ^^^^^^^^^^^^^^^ Provide Default Value So here my results for that code-example: and now i try to figure out how i can enter more xpath queries at the above mentioned codeand get out even more important data - see here Key:contact - OpenStreetMap Wiki i will digg into all documents and come back later the weekend... and report all the findingswell - i think that i need to extend the xpath requests within the loop where xpath is used again,now relative to those school nodes to see if there is a name and if so to fetch it: tag[@k = "name"]/@v'tag[@k = " contact:website"]/@v'tag[@k = " contact:email"]/@v' What do you say...?many many thanks to you for all your help. You are very supportive. Keep up the superb work here....
  10. Hi,I am very new to this forum. I started learning XPath queries.Can anyone please assist me on how to get elements from an xml which doesn't have a root element. For example: The xml: <book id="bk101"> <author>Gambardella, Matthew</author> <description>with XML.</description> </book> <book id="bk201"> <author>Gambardella, Matthew</author> <description>with XML.</description> </book> <book id="bk301"> <author>Gambardella, Matthew</author> <description>with XML.</description> </book> Now I want to get a book element where the book id is bk101. Thanks in advance, Vishwanath Thanks,Vishwanath
  11. Some quick context to what I'm doing. I'm utilizing a test automation tool called SOASTA. What this software allows me to do is record performed actions on a mobile device and then play back those same actions at anytime. When recording actions, SOASTA will assign the action performed a random locator value. This value can be modified to equal a specific XPATH value. On the mobile application I'm recording action on, I have 3 files stored called TEST SIGN.doc, TEST SIGN.docx, and TEST SIGN.pdf, separated by the node <RelativeLayout> in the XML code shown below. Each of these files have a button on them that when tapped, opens a window to perform certain actions. In the XML hierachy, these three buttons are all assigned the same value of, <DontPressWithParentImageView touchTestId="img_item_action"/>. My question is, is there an XPATH that will allow me to distinguish between the 3 buttons even though the buttons have the same values? THANK YOU IN ADVANCE!! <ListView touchTestId="16908298"> <RelativeLayout> <ImageView touchTestId="img_icon"/> <TextView text="TEST SIGN.doc" touchTestId="txt_title"/> <TextView text="21.5 KB, modified Jan 20, 2014 03:36 PM" touchTestId="txt_info"/> <CheckBox text="" touchTestId="checkbox"/> <View touchTestId="divider"/> <DontPressWithParentImageView touchTestId="img_item_action"/> </RelativeLayout> <RelativeLayout> <ImageView touchTestId="img_icon"/> <TextView text="TEST SIGN.docx" touchTestId="txt_title"/> <TextView text="12.6 KB, modified Jan 20, 2014 03:36 PM" touchTestId="txt_info"/> <CheckBox text="" touchTestId="checkbox"/> <View touchTestId="divider"/> <DontPressWithParentImageView touchTestId="img_item_action"/> </RelativeLayout> <RelativeLayout> <ImageView touchTestId="img_icon"/> <TextView text="TEST SIGN.pdf" touchTestId="txt_title"/> <TextView text="12.7 KB, modified Jan 20, 2014 03:36 PM" touchTestId="txt_info"/> <CheckBox text="" touchTestId="checkbox"/> <View touchTestId="divider"/> <DontPressWithParentImageView touchTestId="img_item_action"/> </RelativeLayout></ListView>
  12. Hi everybody, I'm having an XML exam tomorrow and there are still some points which I don't really understand. Appreciate if you could help me understand... Ok No. 1) Regarding the attached XML-Document: What is the result following Address? //md:annotationBody//md:contents[contains(@id, "1")] or //md:annotationBody//md:contents[contains(@id, "2")] My answer was: delivers each element of md:contents which has a 1 or 2 in its id. But the correct answer is: "true" - because with the 'or' the whole expression becomes a predicate. Can someone please explain this for me? I don't really understand the above explenation. No. 2) What is the result of following XQuery? xquery version "1.0";declare namespace xsi = "...."declare default element namespace "Anootation";element root { for %V1 in doc(*./MADCOW.xml*)//textContent[containts(.,"Annotation")] return element A {%V1/../@id}} The answer is: <root xmlns="Annotation"> <A id="1"/> <A id="2"/> </root> But why?? No. 3) Sketch a transformation which returns following information: name of author (author), Title (title) and last content of text (textContent): <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:md="Annotation"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/"> <root> <xsl:apply-templates select="//md:metadata/md:author" /> <xsl:apply-templates select="//md:metadata/title" /> <xsl:apply-templates select="//md:textContent[last()]" /> </root> </xsl:template> <xsl:template match="md:author" > <autor> <xsl:value-of select="."/> </autor> </xsl:template> <xsl:template match="title" > <title> <xsl:value-of select="." /> </title> </xsl:template> <xsl:template match="md:textContent" > <content> <xsl:value-of select="." /> </content> </xsl:template></xsl:stylesheet> Isn't there a simpler way? I don't really understand what it does in line 8 to 14 I'll add other question when they occur. Thank you in advance for your support. Kind regards Mufasa
  13. HI. I need to intergrate several xml documents into a master xml document.I did everything but my problem is that the second xml file prints continouslly. eg No1.xml <root> <name1> some name</name1> <name2> some name </name2></root> <root1> <name1> some name</name1> <name2> some name </name2></root1> No2.xml<anotherRoot> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot> <anotherRoot1> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot1> Expected output <root> <name1> some name</name1> <name2> some name </name2></root> <anotherRoot> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot> <root1> <name1> some name</name1> <name2> some name </name2></root1><anotherRoot1> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot1> But the utput I get<root> <name1> some name</name1> <name2> some name </name2></root> <anotherRoot> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot> <anotherRoot1> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot1> <root1> <name1> some name</name1> <name2> some name </name2></root1> <anotherRoot> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot> <anotherRoot1> <alias> some alias</alias> <alias2> some alias </alias2><anotherRoot1> Is there a function for that.
  14. Here is my xml: <?xml version='1.0' encoding='UTF-8'?><wd:Report_Data xmlns:wd="urn:com.workday.report/CR-INT034-ADP-Garnishment_Disbursements_File-Outbound2"> <wd:Report_Entry> <wd:field>1111</wd:field> </wd:Report_Entry> <wd:Report_Entry> <wd:field>2222</wd:field> </wd:Report_Entry> <wd:Report_Entry> <wd:field>3333</wd:field> </wd:Report_Entry> <wd:Report_Entry> <wd:field>2222</wd:field> </wd:Report_Entry> <wd:Report_Entry> <wd:field>3333</wd:field> </wd:Report_Entry> <wd:Report_Entry> <wd:field>1111</wd:field> </wd:Report_Entry></wd:Report_Data> Here is the xslt I am using: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:wd="urn:com.workday.report/CR-INT034-ADP-Garnishment_Disbursements_File-Outbound2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="2.0"><xsl:strip-space elements="*"/><xsl:output indent="no" method="text" /> <xsl:key name="entry" match="wd:Report_Entry" use="wd:field" /> <xsl:template match="wd:Report_Data"> <xsl:value-of select="count(wd:Report_Entry | wd:field[ generate-id() = generate-id(key('entry', wd:field))])"/> </xsl:template> </xsl:stylesheet> I am trying to count the unique values. So in the example above, the answer should be 3 and I am getting 6. I can get this to work in 1.0 with the following code: <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:wd="urn:com.workday.report/CR-INT034-ADP-Garnishment_Disbursements_File-Outbound2" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"version="1.0"><xsl:strip-space elements="*"/><xsl:output indent="no" method="text" /> <xsl:key name="entry" match="wd:Report_Entry" use="wd:field" /> <xsl:template match="wd:Report_Data"> <xsl:value-of select="count(wd:Report_Entry [ generate-id() = generate-id(key('entry', wd:field))])"/> </xsl:template> </xsl:stylesheet> But I can't use 1.0 I have to use 2.0. Is there any way to get this to work in 2.0 or am I just out of luck? Any help would greatly be appreciated! Thanks,Sarah
  15. I have a peculiar situation where I need to be able to extract the namespace and the name of the first element within the "Body" tag of a soap envelope without knowledge of the soap namespace or the name of the namespace nor the element name within the body. The soap envelope can come in many ways. For examples: <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <I_Need_This_One xmlns="king.kong.loves.godzilla"> <anythingElseDownHere> </anythingElseDownHere> </I_Need_This_One> </S:Body></S:Envelope> or <Soap:Envelope xmlns:Soap="http://schemas.xmlsoap.org/soap/envelope/"> <Soap:Body> <I_Need_This_One xmlns="king.kong.loves.godzilla"> <anythingElseDownHere> </anythingElseDownHere> </I_Need_This_One> </Soap:Body></Soap:Envelope> or <Mothra:Envelope xmlns:Mothra="http://schemas.xmlsoap.org/soap/envelope/"> <Mothra:Body> <I_Need_This_One xmlns="king.kong.loves.godzilla"> <anythingElseDownHere> </anythingElseDownHere> </I_Need_This_One> </Mothra:Body></Mothra:Envelope> And I need the XPath to extract both "I_Need_This_One" and "king.kong.loves.godzilla" into XSL variables. I've tried all kinds of variants of "/*/*[local-name()=Body]/*[local-name()]", and "//*[local-name()=Body]/*[local-name()]", but all I seem to get is everything below "anythingElseDownHere". So, I'm lost as to what to do.
  16. hi I'm new to xslt world. I'm understanding that xslt is not a procedure language. What I'm trying to achieve is a cascaded dropdown list, where the values showed in the lower level dropdown list will be depend on the value selected in the upper level dropdown. The parsing of the data and populating the data to the lower level dropdown is done through javascript. Here is my xml <FormElement type="dropdown" id="Parent" label="CC1" associatedChildID="Child" cascadingLevels="2" required="no" labelafter="" labelAfterStyle="Plain" tooltip="" status="" copy="true" changed="0" visibility="visible"><choice value="1|234" status=""/><choice value="2|345" status=""/><choice value="2|245" status=""/><choice value="2|456" status=""/><choice value="3|456" status=""/><choice value="3|344" status=""/><choice value="4|333" status=""/><choice value="4|567" status=""/><choice value="5|" status=""/><choice value="6|345" status=""/></FormElement> Here is my xslt <xsl:when test="@associatedChildID!=''" ><xsl:variable name="dataVal"><xsl:for-each select="choice"><xsl:value-of select="concat(.,@value,',')"/></xsl:for-each></xsl:variable><asp:DropDownList id="{@id}" runat="server" style="{@visibility}" onchange="populateData(this,'{@associatedChildID}','{$dataVal}','{@cascadingLevels}')" RepeatColumns="5" CssClass="frmValue" ><asp:ListItem Value=""><xsl:value-of select="''"/></asp:ListItem><xsl:variable name="uniqueChecker"><xsl:variable name="listValue" select="substring-before(@value,'|')"/><xsl:for-each select="choice"><[color="#2b91af
  17. I apologize if this is the wrong forum, just wasn't sure where to put this question. I'm trying to return the url from this onclick node: <a onclick=”javascript:getURLWin(‘http://some.web.url/some/path/index.html’); href=”javascript:void(0);”>; here is the block of text which describes the page </a> So far, I've tried td[2]/a/[@onclick=”javascript:getURLWin(‘”;] , and that hasn't worked. Can anyone offer suggestions? Thanks
  18. I am trying to write a document which could help in filtering data from another XML document. E.g. <filter> <what> <include> <marital_staus/> <ms>single</ms> <!--nog = no of groups--> <include> <memberofgroups/> <gn>Football club</gn> <!--user is a member of this club--> </include> </include> </what></filter> What I want this code to do is to choose, first, the users who are members of Football club, and then out of those, chose the users who are single. But I cannot figure out how to write a stylesheet for this. I wrote this: <xsl:template name="temp"> <xsl:param name="a1"/> <xsl:param name="pro"/> <xsl:choose> <xsl:when test="$op = 'marital_status'"> <xsl:for-each select="/document/users/user"> <xsl:if test="marital_status=$a1"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:when> <xsl:when test="$op = 'memberofgroups'"> <xsl:for-each select="/document/users/user"> <xsl:for-each select="./groups/member_of_group"> <xsl:if test=".=$a1"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="include"> <xsl:call-template name="temp"> <xsl:with-param name="a1"> <xsl:apply-templates select="*[2]"/> </xsl:with-param> </xsl:call-template> </xsl:template> While calling the template I pass the correct values I suppose. Problem is I get all the users who are single, plus all the users who are members of that particular group. However I want single users who are also member of Football club. I don't want the stylesheet to be hard-coded, because I also want to do filtering based on other elements. I can not figure out how can I save the filtered elements into something which could be used as an input for the next XPath expression. Or am I making some mistake while writing the constraints for filtering the document. Or could there be any other more appropriate way of writing a document for filtering? I will much appreciate your help. And I have one xml document "document" and two elements "filter" and "users".
  19. Hi all,I have this XSLT: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/><xsl:template match="/"><xsl:apply-templates select="//prime"/></xsl:template> <xsl:template match="prime"> <xsl:apply-templates select="note[@style='tt']" /> </xsl:template> <xsl:template match="note/rss/channel"> <xsl:apply-templates select="item"></xsl:template><xsl:template match="item"><item> <title> <xsl:value-of select="title"/> </title> <description> <xsl:value-of select="description"/> </description> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template><xsl:template match="prime"> <xsl:apply-templates select="note[@style='sms']" /> </xsl:template> <xsl:template match="note/rss/channel"> <xsl:apply-templates select="item"></xsl:template><xsl:template match="item"><item> <title> <xsl:value-of select="title"/> </title> <pubDate> <xsl:value-of select="pubDate"/> </pubDate></item></xsl:template></xsl:stylesheet> I want to show note type =tt and note type = sms in the same page because the content of each type is different, the problem with this xslt is that the note type sms is overwritting the note type = tt, in other words, it's only showing the note type= sms. How can I solve this... Thanks all
  20. Hello, I have an XML file called cookbook.xml as well as an XSL file linked to it, called cookbook.xsl that presents all the information found in the .xml file in an html table (with headings, seperate cells, etc.) Now I want to create an html file that will presenet the above complete table on page load, as well as some query fields above that table, so that the table is refreshed according to a user's input (filters..) More specifically: XML file: For each cookbook (represented by a recipestories element), the file contains information about its title, author(s), year and page numbers, among others As for the HTML file, the user should be able to filter the results appearing on the table as follows: for each of author, title and year, the user should be able to enter a value (e.g. 1990) as well as an operator (e.g., <, =, >) and retrieve the cookbooks satisfying the corresponding conditions (e.g., year=1990). The user should be able to enter conditions for any combination of these three properties. If no conditions are entered, all cookbooks should be returned. For author and title, the user should also be able to enter "contains" as an operator, along with some value. In this case, the system should return cookbooks where the corresponding author or title contains the value entered as a substring. For example, I might want all papers where the title contains the string "choco". The user should also be able to search for cookbookss by their number of authors. Here too an operator and value should be allowed (e.g., all cookbooks with at least 3 authors). The user should be able to specify the property (author, title, pages or year) by which the returned cookbooks should be sorted. This is where I am right now: <html> <script type="text/javascript"> function loadXML(file) //function for loading XML files{ var moz = (typeof document.implementation.createDocument != 'undefined'); var ie = (typeof window.ActiveXObject != 'undefined'); var xmlDoc; if (moz) xmlDoc = document.implementation.createDocument("", "", null); else if (ie) xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.load(file); return xmlDoc;} </script> <script type="text/javascript"> var xmlDoc = loadXML("cookbooks.xml");var stylesheet = loadXML("cookbooks.xsl");var moz = (typeof document.implementation.createDocument != 'undefined');var ie = (typeof window.ActiveXObject != 'undefined'); if (moz){ var nsResolver = stylesheet.createNSResolver(stylesheet.ownerDocument == null ? stylesheet.documentElement:stylesheet.ownerDocument.documentElement); ..........} else if (ie){ var value = stylesheet.selectSingleNode(............} </script> </html> that is pretty basic I know, but I'm also pretty lost and desperate and I don't know where to start from! Do I create an html form with the fields for the queries and a submit button? Do I then take all the values entered in the above form and "spread them out" in that NSResolver function I'm trying to create above, evaluate them and reapply the stylesheet to the xml file accordingly? Help!
  21. Hi guys! I have turned to this forum beacuse I am tired of serching on the web, this problem is already fuzzing my brain. Well lets start from the beginning. I am building an HTML application, with javascript and xml. My XML file is as below: <cadastro> <instrumento> <diareg>2011/11/25</diareg> <id>0107006</id> <idsetor>1</idsetor> <idgrupo>7</idgrupo> <idsequencia>006</idsequencia> <nome>Escala Graduada de Aço</nome> <modelo>Mecanico</modelo> <fabricante>Stanley</fabricante> <nserie>--</nserie> <capacidademin>0.0</capacidademin> <capacidademax>600.0</capacidademax> <resolucao>0.5</resolucao> <unidade>mm</unidade> <complemento>Escala com duas graduações em milímetro e polegada</complemento> <estado>conforme</estado> <tipocalibra>ci</tipocalibra> <procedimento>IT-FLB-53-CQ-037</procedimento> <proxdiacalib>2012/8/21</proxdiacalib> <periodocalib>365</periodocalib> <ficha> <dia>2011/11/25</dia> <certificado>CQ225/11</certificado> <hiperlink>N/A</hiperlink> <diacalib>2011/8/22</diacalib> <erromin>0.0</erromin> <erromax>0.05</erromax> <erromed>0.025</erromed> <incerteza>0.01</incerteza> <situacao>calibrado</situacao> <historico>Disponível para o uso</historico> <status>Conforme</status> <valor>0</valor> </ficha> </instrumento> <instrumento> <diareg>2011/11/25</diareg> <id>0113025</id> <idsetor>1</idsetor> <idgrupo>13</idgrupo> <idsequencia>025</idsequencia> <nome>Micrômetro Externo</nome> <modelo>Mecanico</modelo> <fabricante>Mitutoyo</fabricante> <nserie>86437051</nserie> <capacidademin>0.0</capacidademin> <capacidademax>25.0</capacidademax> <resolucao>0.01</resolucao> <unidade>mm</unidade> <complemento>Micrometro para medição de canal do Zeta.</complemento> <estado>conforme</estado> <tipocalibra>ci</tipocalibra> <procedimento>IT-FLB-53-CQ-037</procedimento> <proxdiacalib>2012/1/16</proxdiacalib> <periodocalib>60</periodocalib> <ficha> <dia>2011/11/25</dia> <certificado>CQ330/11</certificado> <hiperlink>N/A</hiperlink> <diacalib>2011/11/17</diacalib> <erromin>0.1</erromin> <erromax>0.1</erromax> <erromed>0.1</erromed> <incerteza>0.01</incerteza> <situacao>calibrado</situacao> <historico>Disponível para o CQ</historico> <status>Conforme</status> <valor>0</valor> </ficha> </instrumento></cadastro> I`m using this xml file as a simple database for my application, were I control info about instruments as caliper, micrometer, scales, and a lot of measuring equipment.Well as you can see i have "Cadastro" as my root element, "Instrumento" or instrument is the element that holds the info of the equipment.For my problem i have to query on the xml three elements from "instrumento", they are: <idsetor></idsetor>: this one holds the sector which the equipment belongs to. (its a number)<idgrupo></idgrupo>: this oneindicates the group of the equipment like(Digital caliper, Pressure Gauge,...) (its a number) <idsequencia></idsequencia>: this one indicates the sequential number of the equipment by order of arrival and registry (caliper 001, caliper 002, ...,caliper NNN) the <id></id> is a combination formed by the 3 elements above.Well during the registry I input two variables the sector and the group but the sequential number should be generated automaticaly obeying the sequence of the already registered equipments. my logic is request all the instruments with the same <idsetor> and <idgrupo> and after select from this set, the one with the highest <idsequencia>, and then: idsequencia = idsequencia + 1; Now reading about Xpath in the internet I got to this two Xpaths: 1 - "cadastro/instrumento[idsetor=+IDSETORaux+" and idgrupo="+IDGRUPOaux+]/idsequencia"2 - "/cadastro/instrumento/idsequencia[not(/cadastro/instrumento/idsequencia>.)]" The first returns all the <idsequencia> of all the instruments that have the same idsetor and idgrupo, pointed by the variables IDSETORaux and IDGRUPOaux respectively. The second returns te highest <idsequencia> of all the registered elements. Well I have been playing with this two xpaths, combining them in diferent ways but no success. Now i turn to you and ask, can you help me please???
  • Create New...