- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 4
- Posts with Upvotes
- 4
- Upvoting Members
- 4
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
128 Posted Topics
Re: XSL variables are immutable. You cannot change the value of a variable once it is set. If I understand your requirements correctly you are trying to number a simple list. If this is the case, try the following. [code] <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes"/> <xsl:template … | |
Re: You are still thinking in terms of procedural languages such as C or Java. Here is how to do it in a declarative language such as XSL. [code] <?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="UTF-8" indent="yes"/> <xsl:template match="/"> <xsl:element name="root"> <xsl:apply-templates select="catalog/cd/artist"/> </xsl:element> </xsl:template> <xsl:template match="catalog/cd/artist"> <xsl:element … | |
Re: Here is a java applet. [url]http://media.pearsoncmg.com/aw/aw_kurose_network_2/applets/csmacd/csmacd.html[/url] | |
| |
Re: Try [code] mountPoint="`df -h | grep $pth | tr -s ' ' | cut -d ' ' -f6`" [/code] BTW, you could significantly simplify things by piping df output to awk | |
Re: Assuming the revised document looks like this [code] <?xml version="1.0"?> <root> <word id="4"> <text>Joe</text> </word> <word id="2"> <text>name</text> </word> <word id="3"> <text>is</text> </word> <word id="1"> <text>My</text> </word> </root> [/code] then [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="theID" select='1' /> <xsl:key match="word" name="idkey" use="@id"/> <xsl:template match="root"> <xsl:value-of select="key('idkey',$theID)/text"/><xsl:text> … | |
Re: It is hard to help you. There is no relationship between input document and the expected output document. For example where is Button 2 in the input document? | |
Re: If you are using ksh93 (Korn Shell 93) , date manipulation is builtin, i.e. [code] $ printf "%(%y%m%d)T\n" yesterday 100318 $ [/code] | |
Re: You might want to also remove all the resulting whitespace by adding [code] <xsl:strip-space elements="*"/> [/code] to the stylesheet provided by iceandrews. | |
Re: Just for completeness, here is an XSL1.0 solution. A wildcard ('*') namespace prefix is not permitted in XSLT1.0. The solution is to match using the local-name() function. [code] xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="*[local-name()='AccountWS_AccountQueryPage_Output']"/> </xsl:template> <xsl:template match="*[local-name()='AccountWS_AccountQueryPage_Output']"> <xsl:copy> <xsl:apply-templates select="*[local-name()='LastPage']"/> <xsl:apply-templates select="*[local-name()='ListOfAccount']"/> </xsl:copy> </xsl:template> <xsl:template match="*[local-name()='ListOfAccount']"> … | |
Re: This works for XSLT1 [code] <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="product"> <product> <xsl:attribute name="display"> <xsl:value-of select="display/@value"/> </xsl:attribute> <xsl:attribute name="count"> <xsl:value-of select="count/@value"/> </xsl:attribute> </product> </xsl:template> </xsl:stylesheet> [/code] | |
Re: XSLT1.0 does not have built-in date arithmetic. Have a look at [url]http://exslt.org/date/index.html[/url] fo extension functions which handle dates. Some of the functions should enable you to do what you want to do. XSLT2.0 has the subtract-dates series of functions | |
Re: Have a look at the following post: [url]http://www.daniweb.com/code/snippet217275.html[/url] | |
Re: [code] <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="resultset" > <groceries xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <xsl:apply-templates select="*"/> </groceries> </xsl:template> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> [/code] outputs the following: [code] <?xml version="1.0"?> <groceries xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <row> <sample>cereal</sample> <count>1</count> </row> <row> <sample>macaroni</sample> <count>1</count> </row> <row> <sample>cookies</sample> <count>2</count> </row> <row> <sample>rice</sample> … | |
Re: If you are using ksh93 you can use the print %T syntax to achieve what you want to do [code] $ date="08/02/2010" $ print $date 08/02/2010 $ date=$(printf "%(%-m/%-d/%Y)T" "$date") $ print $date 8/2/2010 $ [/code] | |
Re: This should do what you want: [code] <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:freshness="http://freshness" xmlns:history="http:history" xmlns:wo="http:hello"> <xsl:output method="xml" indent="no"/> <xsl:template match="/|comment()|processing-instruction()"> <xsl:copy> <!-- go process children (applies to root node only) --> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="*"> <xsl:element name="{local-name()}"> <!-- go process attributes and children --> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> … | |
Re: This article might help you: [url]http://www.informit.com/articles/article.aspx?p=26881[/url] | |
Re: Here is a simple example of how to do it. Suppose you have the following XML file [code] <timesheet> <date>04072010</date> </timesheet> [/code] and you apply the following stylesheet to it [code] <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> <xsl:template match="date"> <xsl:element name="date"> <xsl:call-template … | |
Re: I don't think you can do what you want to do. I don't know of any place where all the Festival APIs are documented other than the source code Some but not all of the APIs are documented here: [url]http://www.cstr.ed.ac.uk/projects/festival/manual/festival_28.html#SEC126[/url] Why not ask your question on the Festival mailing list. … | |
Re: I totally agree with sourceview [quote] Second, I don't want Stallman to enter into my decision of what is right for me! I want the server, desktop and embedded distros that best meet my personal needs and my business needs, not the needs and desires of a socialist and/or other … | |
Re: Your question is not very clear to me. An example of what you want would help. | |
Re: Here is a non-recursion based solution: [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" /> <xsl:template match="/"> <xsl:element name="X"> <xsl:attribute name="name"> <xsl:value-of select="//B[1]/C" /> </xsl:attribute> <xsl:element name="Y"> <xsl:attribute name="name"> <xsl:value-of select="//B[2]/C" /> </xsl:attribute> <xsl:element name="Z"> <xsl:attribute name="name"> <xsl:value-of select="//B[3]/C" /> </xsl:attribute> </xsl:element> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> [/code] | |
Re: If you are using XSLT1, the easiest way is to use the date:difference() in EXSLT. If you are using XSLT2 the subtraction of two dates gives a xs:dayTimeDuration which a ISO 8601 truncated format PnDTnHnMnS, where nD represents the number of days, T is the date/time separator, nH the number … | |
Re: Wheter do you want this section to be inserted into? | |
Re: [code] <xsl:template match="/"> <xsl:value-of select="count(//title[@classification='computing' and following-sibling::year > 2000] )" /> </xsl:template> [/code] | |
Re: You cannot display Japanese code points using ISO-8859-1 (Latin-1). All XML processors must support at least UTF-8 and UTF-16 but not necessarily other encodings. You need to specify a suitable encoding for the particular Japanese syllabary that you are using, i.e. Hiragana, Katakana, Kanji or Romaji | |
Re: You need to replace all instances of "&" with "&" | |
Re: Without seeing your XML file, I cannot give a precise answer. The element you need to use is <xsd:unique> and your schema modification should look something like this: [code] <xsd:unique name= "uniqueId"> <xsd:selector xpath="./yourxpath" /> <xsd:field xpath="@Id"/> </xsd:unique> [/code] | |
Re: Here is one way of doing it. [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="Employee"> <Employee> <xsl:apply-templates select="EmployeeDetails" /> </Employee> </xsl:template> <xsl:template match="EmployeeDetails"> <xsl:variable name="employee" select="@EmployeeName" /> <xsl:variable name="id" select="@EmployeeId" /> <xsl:element name="EmployeeDetails"> <xsl:attribute name="{$employee}"><xsl:value-of select="$id" /></xsl:attribute> <xsl:attribute name="CompanyName"><xsl:value-of select="@CompanyName" /></xsl:attribute> <xsl:attribute name="CompanyAddress"><xsl:value-of select="@CompanyAddress" /></xsl:attribute> <xsl:attribute name="ContactNo"><xsl:value-of select="@ContactNo" … | |
Re: You can eliminate the spurious xmlns="" by adding the namespace prefix to the NewNode element, i.e. [code] <xsl:template match="a:*[@Mark]"> <xsl:variable name="the_val" select="/a:Top/a:Wanted/@Val"/> <a:NewNode NewVal="{$the_val}" /> </xsl:template> [/code] This produces the following output [code] <Top xmlns="http://foo.bar.com/something"> <Wanted Val="get this"/> <NewNode NewVal="get this"/> </Top> [/code] BTW, if you are using a XSLT … | |
Re: This should help you: [url]http://www.dpawson.co.uk/xsl/sect2/flatfile.html[/url] | |
Re: You cannot redirect to another stylesheet. You can, however, include or import another stylesheet using the <xsl:import> or <xsl:include> instructions. | |
Re: Here is a stylesheet which will do what you want to do. I have simplied it to just output the result as a text value. It uses recursion. You cannot use a for loop to do what you want to do. [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="text" … | |
Re: Looks like a valid XML file to me. BTW, a good site to use to check your XML for well-formedness, valid DTDs, etc is [URL="http://www.validome.org/"]http://www.validome.org/[/URL] | |
Re: [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" /> <xsl:template match="b"> <xsl:copy-of select = "."/> </xsl:template> </xsl:stylesheet> [/code] | |
Re: This is should be close to what you want. [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="*"> <xsl:variable name="name" select="name()" /> <xsl:element name="{name()}"> <xsl:attribute name="id"> <xsl:value-of select="count(preceding::*[name()=$name]) + 1" /> </xsl:attribute> <xsl:apply-templates /> </xsl:element> </xsl:template> </xsl:stylesheet> [/code] | |
Re: One way would be to extract the CDATA first [code] <?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="ForwardRequestResponse"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="/"> <xsl:apply-templates select="ForwardRequestResponse"/> </xsl:template> </xsl:stylesheet> [/code] and then process it though an XML pretty printer such as [code] <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:param name="indent-increment" select="' … | |
Re: There is no simple way to do what you want using XSLT because of the multiple namespace declarations in the root element. In fact, the simpliest way is to use a stream editor such as sed. However, if you are willing to accept a slight modification of the file to … | |
![]() | Re: one way ... [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" /> <xsl:template match="/ts"> <ts> <xsl:apply-templates /> </ts> </xsl:template> <xsl:template match="uc"> <uc> </uc> </xsl:template> </xsl:stylesheet> [/code] |
Re: [code] <?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="CustomerRet"> customerName=<xsl:value-of select="./customerName"/> id=<xsl:value-of select="./customerId"/> customeField=<xsl:value-of select="./customField"/> </xsl:template> <xsl:template match="/"> <xsl:apply-templates /> </xsl:template> </xsl:stylesheet> [/code] Here is the output for the example xml file you supplied [code] customerName=Jack id=1 customeField=A customerName=Jack id=1 customeField= [/code] | |
Re: Since nobody else has offered a solution, I will try and help you. Here is one way of generating lines 4 and 5 of the desired output. [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/root"> <xsl:apply-templates /> </xsl:template> <xsl:template match="titel/bold"> <nummer><bold><xsl:value-of select="normalize-space(text()[1])"/></bold></nummer><xsl:text> </xsl:text><text><bold><xsl:copy-of select="descendant::node()[position()>2]"/></bold></text> </xsl:template> </xsl:stylesheet> [/code] The … | |
| |
Re: As far as I know you cannot use an XPath expression to do what you want to do. Here is how I get the result you are looking for [code] <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/" > <xsl:element name="PO"> <xsl:copy-of select="//ITEM[ID='1000']" /> </xsl:element> </xsl:template> </xsl:stylesheet> … | |
Re: [code] <xsl:variable name="dummy" select= "/ArrayOfBookMark/BookMark[ShortName='Asp-7042-EndVar1']/Value" /> <xsl:variable name="dummy1"> <xsl:choose> <xsl:when test="$dummy != ''">$dummy</xsl:when> <xsl:otherwise>$</xsl:otherwise> </xsl:choose> </xsl:variable> [/code] | |
Re: [code] <xsl:if test="//text()[contains(., 'Sales')]"> <xsl:copy-of select="." /> </xsl:if> [/code] | |
Re: f you can specify the transformation you want to implement, then we can help you turn this specification into XSLT code. If you can't specify the transformation, then your problem is not an XSLT problem, and you're unlikely to get help on this forum. | |
Re: Please provide an example so we have a clearer understanding of your question. | |
Re: Here is a stylesheet which will do what you want [CODE] <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <!-- pass in as -param uid "'value'" --> <xsl:param name="uid"/> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:element name="staff"> <xsl:apply-templates select="//user"/> </xsl:element> </xsl:template> <!-- output nodes that match --> <xsl:template match="user"> <xsl:if test="id=$uid"> <xsl:element name="user"> <xsl:element … |
The End.