js |
JavaScriptタグが付けられた新着投稿 - Qiita |
WSH TypeScript with ES Modules |
https://qiita.com/mukai1011/items/f97cff32f36c1b595dd5
|
htypescriptwithesmodules |
2022-05-15 15:16:12 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Alfred WorkflowでSlack投稿いろいろ |
https://qiita.com/kentoak/items/9705613fd1b690a87da8
|
howtoins |
2022-05-15 15:08:48 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
WSL 上に Re:dash をインストールするまで |
https://qiita.com/taiseiyo11/items/42d0f2a891cf40a5141c
|
redash |
2022-05-15 15:49:57 |
海外TECH |
DEV Community |
Your First Step To Write XSLT |
https://dev.to/engineermostafa/your-first-step-to-write-xslt-1em
|
Your First Step To Write XSLT Introduction about XSLT The XSLT is the abbreviation of eXtensible Stylesheet Language Transformationxslt is a language of transforming XML documents so we can consider it as a style sheet for XML like CSS is a style sheet for HTML also the XSLT files extensions end with xslt or xsl each of them is a valid extension Why to use XSLT we can transform XML file to another XML file after making some modifications also we have the ability to convert XML file to HTML page like this example we have some products in a category and we need to create a table with these products lt xml version encoding UTF gt lt category gt lt product gt lt name gt watch lt name gt lt price gt lt price gt lt product gt lt product gt lt name gt IPhone lt name gt lt price gt lt price gt lt product gt lt product gt lt name gt wallet lt name gt lt price gt lt price gt lt product gt lt category gt that was done just with XSLT code so lets go a little bit deep in XSLT XSLT Basic Architecture ElementsWe have some element that we can use in xslt language you can find most of them in the referencefor each and value of are called elements so as a conclusion every param after xsl is called element lt xsl for each select expression gt lt Content gt lt xsl for each gt lt xsl value of select expression disable output escaping yes no gt and by the way any word written beside the element within its scope in lt gt signs is called attribute so if i need to add id for each product i can put id attribute in each product element like that lt product id gt lt name gt watch lt name gt lt price gt lt price gt lt product gt but how to use these elements and how to tell the editor to include these elements and recognize them all of these questions s answer is namespace of this language NamespaceThe first thing you should write in xslt file is the namespace and you can write it with two different ways but with the same result at the end lt xsl stylesheet version xmlns xsl gt lt xsl transform version xmlns xsl gt xsl stylesheet and xsl transform are completely identical in the functions Variableswe can declare as usual in programming languages global or local variable but the difference here is once you set the variable s value you can t modify or change that value so it is consider as final in language like Java PHP and Dart let s go forward to see how to declare a variable lt xsl variable name name select expression gt lt xsl variable gt lt xsl variable name color select red gt the name of variable can be set in the name attribute also the value of the variable can be set in select attribute but we have one constrain here that we should put variable s value if it will be a string in quotes like red in the example not just put the value LoopsIts very easy in other language to write a for loop just write for with specific condition also here its a quite similar but with different keyword xsl for each so it will be like that lt xsl for each select expression gt lt Content gt lt xsl for each gt We will put in the select attribute the path of element that we need to loop in like in our category product example we should put the path of products like that lt xsl for each select category product gt lt Content gt lt xsl for each gt so now in this point we are ready to loop over all products with the final step to get the name of the product and the price to put them into table but how about if we need to just show the product with specific price by checking the price if it is higher than or less than or equal to an arbitrary value of course as you thought so lets go and eat a very delicious meal conditions ConditionsWe have two ways to make a conditions the first one like usual if lt xsl if test expression gt some output if the expression is true lt xsl if gt as we know now test is attribute we should put our condition instead of expression in the test attribute but as not usual we have constant symbols for comparing amp gt gt means greater than amp lt gt means less than gt means equal gt means not equallike if we need products which prices are greater than so stuff like that can be done by using loops and conditions together as shown lt xsl for each select category product gt lt xsl if test price amp gt gt lt Content gt lt xsl if gt lt xsl for each gt the second way is like switch case in other languages in xslt called choose when lt xsl choose gt lt xsl when test expression gt lt Content gt lt xsl when gt lt xsl otherwise gt lt Content gt lt xsl otherwise gt lt xsl choose gt also we can add when statements as we need now lets implement the condition of products but with choose when lt xsl for each select category product gt lt xsl choose gt lt xsl when test price amp gt gt lt display product gt lt xsl when gt lt xsl otherwise gt lt hide product gt lt xsl otherwise gt lt xsl choose gt lt xsl for each gt but what can we do if we will write the same code in different places to make some logic but in a typical way yes you are right use functions lets do it FunctionsIn c to write function you need to write its name and parameters also its return value type here we just need name and parameter so you can return any type you need lt xsl function name functionName gt lt xsl param name param gt lt xsl param name param gt lt xsl value of select return value gt lt xsl function gt so it is very easy to declare a function also it is very easy to call it like that lt xsl value of select functionName param param gt can you tell me what does this function do lt xsl function name arbitraryName gt lt xsl param name param gt lt xsl param name param gt lt xsl value of select param param gt lt xsl function gt lt xsl value of select arbitraryName param param gt yes you are right just add numbers Great let me tell you congratulations you are now ready to see how could we write the file that convert xml to html tables but one step before do you remember lt Content that we always wrote in if s body also in for s body ok great we could replace this comment with what we want like html tags if we need to convert xml file to html or xml elements whatever want do you imagine what you will see now in the code yes exactly just i will add some html tags that construct the tables and put some CSS styling in the tag so it will be easy peasy dude lt namespace and version gt lt xml version gt lt xsl stylesheet version xmlns xsl gt lt access the root element gt lt xsl template match gt lt html gt lt body gt lt h align center gt My Products Collection lt h gt lt table border align center gt lt tr bgcolor acd gt lt th gt Name lt th gt lt th gt Price lt th gt lt tr gt lt access the path to products gt lt xsl for each select categoryproduct gt lt display all product without any conditions gt lt tr gt lt td gt lt xsl value of select name gt lt td gt lt td gt lt xsl value of select price gt lt td gt lt tr gt lt xsl for each gt lt table gt lt body gt lt html gt lt xsl template gt lt xsl stylesheet gt Conclusion What we did with Xslt we can also did with any programming language but in some cases choice of xslt is more powerful and optimized than coding with your language |
2022-05-15 06:36:55 |
海外ニュース |
Japan Times latest articles |
Tourism and logistics: Okinawa’s latest plan to boost its economy |
https://www.japantimes.co.jp/news/2022/05/15/national/okinawa-economic-development-local-leaders/
|
Tourism and logistics Okinawa s latest plan to boost its economyUnder its latest economic plan Okinawa aims to raise its gross prefectural product from trillion in fiscal to trillion by and |
2022-05-15 15:59:14 |
海外ニュース |
Japan Times latest articles |
North Korea has resumed work at long-dormant nuclear reactor, satellite images reveal |
https://www.japantimes.co.jp/news/2022/05/15/asia-pacific/north-korea-yongbyon-nuclear-reactor/
|
North Korea has resumed work at long dormant nuclear reactor satellite images revealPhotos indicate that the isolated North has resumed construction at the megawatt reactor at its Yongbyon nuclear complex as it looks to further build |
2022-05-15 15:51:25 |
海外ニュース |
Japan Times latest articles |
Okinawa marks 50 years since reversion from U.S. rule |
https://www.japantimes.co.jp/news/2022/05/15/national/okinawa-reversion-anniversary/
|
Okinawa marks years since reversion from U S ruleOkinawa continues to shoulder the bulk of U S bases in the country despite its long stated hope of becoming a peaceful island free of military bases |
2022-05-15 15:35:50 |
海外ニュース |
Japan Times latest articles |
U.S. gunman kills 10 in racially motivated shooting at New York market |
https://www.japantimes.co.jp/news/2022/05/15/world/crime-legal-world/buffalo-market-shooting/
|
U S gunman kills in racially motivated shooting at New York marketAn year old white gunman shot people to death and wounded three others at a grocery store in a Black neighborhood of Buffalo New York |
2022-05-15 15:27:32 |
ニュース |
BBC News - Home |
Andrew Symonds: Former Australia cricketer dies aged 46 in car crash |
https://www.bbc.co.uk/sport/cricket/61453300?at_medium=RSS&at_campaign=KARANGA
|
crash |
2022-05-15 06:07:06 |
ニュース |
BBC News - Home |
'Am I the only one with hearing aids and alopecia?' |
https://www.bbc.co.uk/news/uk-england-shropshire-61391738?at_medium=RSS&at_campaign=KARANGA
|
davies |
2022-05-15 06:22:10 |
ニュース |
BBC News - Home |
Jermell Charlo knocks out Brian Castano to become undisputed champion |
https://www.bbc.co.uk/sport/boxing/61454533?at_medium=RSS&at_campaign=KARANGA
|
Jermell Charlo knocks out Brian Castano to become undisputed championAmerican Jermell Charlo becomes the first undisputed light middleweight champion in history with a th round knock out of Argentina s Brian Castano |
2022-05-15 06:31:19 |
北海道 |
北海道新聞 |
エルパソ秋山が米で初本塁打 パドレス傘下のマイナー3A |
https://www.hokkaido-np.co.jp/article/680995/
|
大リーグ |
2022-05-15 15:12:00 |
北海道 |
北海道新聞 |
上川管内216人感染 旭川は171人 新型コロナ |
https://www.hokkaido-np.co.jp/article/680994/
|
上川管内 |
2022-05-15 15:08:00 |
北海道 |
北海道新聞 |
3年ぶり洞爺湖マラソン開催 ハーフに1262人快走 |
https://www.hokkaido-np.co.jp/article/680991/
|
洞爺湖町 |
2022-05-15 15:04:11 |
IT |
週刊アスキー |
マックのハッピーセットに「ジュラシック・ワールド/サバイバル・キャンプ」のクラフトトイや「リラックマ」が登場 |
https://weekly.ascii.jp/elem/000/004/091/4091450/
|
限定 |
2022-05-15 15:30:00 |
コメント
コメントを投稿