[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Retrieving Complete XPATH from XML File
Why some xpath test attribute's value and others not ? ----- Message d'origine ----- De : "Ramkumar.V" <ramkumar.v@xxxxxxxxx> @ : <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Envoyi : mardi 9 novembre 2010 07:44 Objet : Retrieving Complete XPATH from XML File > Hi, List > > How to get complete XPATH from XML file as shown below? I am using > xslt2.0with saxon9? > > Input XML: > ======== > <?xml version="1.0" encoding="utf-8"?> > <quizzes> > <quiz id="Q1.1" title="Biochemistry 1.1 Quiz" maxQuestions="4"> > <question id="quiz1_1_question1" type="mc"> > <prompt>1. Biochemistry is based on the chemistry of which element?</prompt> > <option id="0">Hydrogen</option> > <option id="1">Oxygen</option> > <option id="2" correct = "true">Carbon</option> > <option id="3">Sulfur</option> > <feedback id="0">Incorrect.</feedback> > <feedback id="1">Incorrect.</feedback> > <feedback id="2">Correct!</feedback> > <feedback id="3">Incorrect.</feedback> > </question> > </quiz> > </quizzes> > > Expected Output 1(Only Nodes): > ========================= > quizzes > quizzes/quiz > quizzes/quiz/question > quizzes/quiz/question/prompt > quizzes/quiz/question/option > quizzes/quiz/question/option > quizzes/quiz/question/option > quizzes/quiz/question/option > quizzes/quiz/question/feedback > quizzes/quiz/question/feedback > quizzes/quiz/question/feedback > quizzes/quiz/question/feedback > > Expected Output 2 (With Attributes): > ============================ > quizzes > quizzes/quiz[@id][@title][@maxQuestions] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/prompt > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/option[@id] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/option[@id] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/option[@id][@co rrect='true'] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/option[@id] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/feedback[@id='0 '] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/feedback[@id='1 '] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/feedback[@id='2 '] > quizzes/quiz[@id][@title][@maxQuestions]/question[@id][@type]/feedback[@id='3 '] > > XSLT tried: > ========= > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0" > > <xsl:output method="text" encoding="UTF-8"/> > <xsl:template match="/"> > <xsl:for-each select="descendant-or-self::node()"> > <xsl:value-of select="local-name()"/> > </xsl:for-each> > </xsl:template> > </xsl:stylesheet> > > Regards, > Ramkumar V > > > > > =========================================================== > ***Disclaimer*** > > > This email, and any attachments ("this email"), is confidential. If you are not the addressee please tell the sender immediately, and destroy this email without using, sending or storing it. Any opinions, express or implied, in this email, are those of the sender, and are not necessarily approved by the company. Except as expressly stated, this e-mail should not be regarded as an offer, solicitation, recommendation or agreement to buy or sell products or services, or to enter into any contract. E-mail transmissions are not secure and may suffer errors, viruses, delay, interception and amendment. The company does not accept liability for damage caused by any of the foregoing. > > ALL INCOMING AND OUTGOING MAILS MAY BE MONITORED BY THE COMPANY. > ============================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|