XML : cum pot sa caut in denumirea, unui atribut?
![]() ![]() ![]() |
XML : cum pot sa caut in denumirea, unui atribut?
GeorgeB |
![]()
Post
#1
|
||
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
|
||
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|||
MoneyTalks |
![]()
Post
#2
|
![]() - Group: Members Posts: 2.712 Joined: 18 April 03 From: Ireland ![]() |
Ce folosesti pentru analiza codului?
|
--------------------
Lexus
ES300H
2020 Religia a aparut cind primul ticalos s-a intilnit cu primul prost
Never underestimate the power of stupidity in large groups |
|
GeorgeB |
![]()
Post
#3
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
codul il prelucrez in visual . net
am o pagina XML care o transform cu un XSLT. problemea mea este ca am niste itemuri recursive pe acolo ![]() am ceva de genul: <doc> <item/> </doc> unde item : <item> <h></h> <b></b> <item></item> </item> ![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MoneyTalks |
![]()
Post
#4
|
![]() - Group: Members Posts: 2.712 Joined: 18 April 03 From: Ireland ![]() |
La acea parcurgere recursiva ai un case care iti rezolva problema.
|
--------------------
Lexus
ES300H
2020 Religia a aparut cind primul ticalos s-a intilnit cu primul prost
Never underestimate the power of stupidity in large groups |
|
GeorgeB |
![]()
Post
#5
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
exemplu te rog
![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MoneyTalks |
![]()
Post
#6
|
![]() - Group: Members Posts: 2.712 Joined: 18 April 03 From: Ireland ![]() |
Folosesti o functie numita startelement? In acea functie analizezi ce te intereseaza.
|
--------------------
Lexus
ES300H
2020 Religia a aparut cind primul ticalos s-a intilnit cu primul prost
Never underestimate the power of stupidity in large groups |
|
GeorgeB |
![]()
Post
#7
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
am gasit asta
![]() CODE //region[starts-with(@name, 'S')] ---------------------------------------- sau ---------------------------------------- //region[contains(@name, 'east')] din msdn : Processing Text Strings by Using String Functions |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MoneyTalks |
![]()
Post
#8
|
![]() - Group: Members Posts: 2.712 Joined: 18 April 03 From: Ireland ![]() |
In principiu ai 3 functii:
startElement: cind incepe un element endElement: cind se termina un element charData: cind analizezi continutul (valoarea) atributului Fiecare din aceste functii are un case, care analizeaza elementele pe care le poti avea in fisierul analizat (deci le faci particulare la ceea ce ai nevoie) In aceste functii scrii codul de care ai nevoie. Denumirile functiilor poate diferi, dar in esenta fac acelasi lucru |
--------------------
Lexus
ES300H
2020 Religia a aparut cind primul ticalos s-a intilnit cu primul prost
Never underestimate the power of stupidity in large groups |
|
GeorgeB |
![]()
Post
#9
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
daaaaaaaaaaa , multumesc. testez acum sa vad dc functioneaza
![]() acum pb este cum parcurge xml ul ? pe fiecare nivel SAU pe fiecare nivel pana la element final si pe urma ia urmatorul element de pe nivel . adica : (1) (11) (12) ... (2) (3) sau (1) (2) (3) (11) (12) .... |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#10
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
hmmmm...
la mine id urile ITEM urilor sunt de genul : do do|ca1 do|ca1|se1 do|ca2 do|ca2|se1 do|ca2|se2 cum pot sa-i spun : adu-mi toate elementele care sunt sectiuni (se) ? oricum am mai avansat , multumesc ![]() never mind . ![]() ![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#11
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
ei bine :
daca ii dau sa-mi aduca toate elementele (nodurile) care au in componenta 'ca' atunci imi aduce : '%ca%|se|...' adica imi aduce tot ce se gaseste pe acea ramura dupa ce a gasit un element ce contine 'ca' |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#12
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
cum ii pot spune : bre, afiseaza-mi doar valoare respectivului element nu si fii lui ...
|
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#13
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
rezolvarea:
pentru a parcurge un fisier XML iregular, care contine elemente recursive(conform MSDN Irregular Data Hierarchies) : se folosesc template uri : Example of Transforming Irregular Data Hierarchies This example illustrates the data-driven model of XSLT processing. With the data-driven model, you can create isolated templates for the types of nodes you expect to see in the output, without too much consideration of their structure. In places where the structure is locally known, you can use <xsl:for-each> and <xsl:value-of> to populate the template. For example, <list> and <item> elements appear in a regular and predictable structure. The capacity to switch smoothly between data-driven and template-driven transformation is an important feature of XSLT. XML File (pole.xml) <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="poleeasy.xsl"?> <document> <title>To the Pole and Back</title> <section> <title>The First Day</title> <p>It was the <emph>best</emph> of days, it was the <emph>worst</emph> of days.</p> <list> <item><emph>best</emph> in that the sun was out.</item> <item><emph>worst</emph> in that it was 39 degrees below zero.</item> </list> <section> <title>Lunch Menu</title> <list> <item>ice cream</item> <item>popsicles</item> </list> </section> </section> <section> <title>The Second Day</title> <p>Ditto the first day.</p> </section></document> XSLT File (poleeasy.xsl) <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <HTML> <HEAD> <TITLE><xsl:value-of select="document/title"/></TITLE> </HEAD> <BODY> <H1><xsl:value-of select="document/title"/></H1> <xsl:apply-templates select="document/section"/> </BODY> </HTML> </xsl:template> <xsl:template match="section"> <DIV> <H2><xsl:value-of select="title"/></H2> <xsl:apply-templates /> </DIV> </xsl:template> <xsl:template match="p"> <P><xsl:apply-templates /></P> </xsl:template> <xsl:template match="list"> <UL> <xsl:for-each select="item"> <LI><xsl:apply-templates /></LI> </xsl:for-each> </UL> </xsl:template> <xsl:template match="emph"> <I><xsl:apply-templates /></I> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> <xsl:template match="title"/> </xsl:stylesheet> Formatted Output Processor Output The white space has been adjusted for clarity. <HTML> <HEAD> <TITLE>To the Pole and Back</TITLE> </HEAD> <BODY> <H1>To the Pole and Back</H1> <DIV> <H2>The First Day</H2> <P>It was the <I>best</I> of days, it was the <I>worst</I> of days.</P> <UL> <LI><I>best</I> in that the sun was out.</LI> <LI><I>worst</I> in that it was 39 degrees below zero.</LI> </UL> <DIV> <H2>Lunch Menu</H2> <UL> <LI>ice cream</LI> <LI>popsicles</LI> </UL> </DIV> </DIV> <DIV> <H2>The Second Day</H2> <P>Ditto the first day.</P> </DIV> </BODY> </HTML> |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MariusI |
![]()
Post
#14
|
![]() Membru autentic Group: Members Posts: 344 Joined: 24 March 03 From: Bucuresti ![]() |
Daca vrei sa gasesti numai atributele cu un anumit tip de nume poti sa faci foarte usor asta cu expresii regulate. Daca imi spui cum arata numele pot sa iti fac eu expresia regulata.
Daca te grabesti, da un pm |
--------------------
Solenza
Scala Dixit.
|
|
GeorgeB |
![]()
Post
#15
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
am facut sa-mi afiseze si elementele recursive folosind exemplul de mai sus , cu template uri.
acum revin la intrebare initiala , cum fac sa caut un element dupa ce contine o bucata din id ul lui ? si inca ceva. cum fac sa ma refer la tatal elementului pe care ma aflu eu ? |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MariusI |
![]()
Post
#16
|
![]() Membru autentic Group: Members Posts: 344 Joined: 24 March 03 From: Bucuresti ![]() |
..cu riscul de a ma repeta: cu expresii regulate
![]() Adica: parcurgi tot tree-ul, cum vrei tu, si compari fiecare atribut cu o expresie regulata . |
--------------------
Solenza
Scala Dixit.
|
|
GeorgeB |
![]()
Post
#17
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
ok. uite in ce stadiu ma aflu:
eu ma aflu cu parser ul pe un element copil. vreau sa aflu ce id are elementul tata. cum fac asta ? |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#18
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
adica eu am ceva de genul :
<doc> <item/> </doc> unde item : <item> <h></h> <b></b> <item></item> </item> ma aflu inauntru unui item , vreau sa-l formatez conform cu un ss. pentru a face asta fac un choose , cu cate un div pt fiecare tip de formatare. determinarea tipului de formatare il fac dupa id ul parintelui. si mai am o intrebare : atributele sau variabilele se pot defini intr-un template si folosi in altul ? |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MariusI |
![]()
Post
#19
|
![]() Membru autentic Group: Members Posts: 344 Joined: 24 March 03 From: Bucuresti ![]() |
Pai daca ai nodul intr-o structura XmlNode, e simplu, il ai in proprietatea ParentNode. Daca nu, poti sa-l obtii in ciclul in care parcurgi arborele si sa ti-l pasezi ca parametru..
Edit: acum am citit mai cu atentie postul, eu am avut impresia ca ai o rutina in vb.net sau c# si la aia ma ofeream sa ajut ![]() |
--------------------
Solenza
Scala Dixit.
|
|
GeorgeB |
![]()
Post
#20
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
pai am vrut sa-l pasez ca paramentru dar nu a vrut. nenorocitul grrrrrrr....
hai ca pana la urma il fac eu pe el ![]() ancestor:: nu merge ? sau mai bine zis cum se utilizeaza ca la mine nu vrea ca in ecemplu ![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#21
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
nuuuuuuu...
![]() eu vreau sa fac o transformare si o parcurgere direct in XSL folosind Xpath ul . ca dc era sa scriu niste cod ii trageam repede de tot . |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
MoneyTalks |
![]()
Post
#22
|
![]() - Group: Members Posts: 2.712 Joined: 18 April 03 From: Ireland ![]() |
Vezi aici e documentatie care iti explica ce si cum
|
--------------------
Lexus
ES300H
2020 Religia a aparut cind primul ticalos s-a intilnit cu primul prost
Never underestimate the power of stupidity in large groups |
|
neumann |
![]()
Post
#23
|
![]() Membru autentic Group: Members Posts: 783 Joined: 6 November 03 From: Spermezeu ![]() |
Am auzit ceva de XPath queries... Nu poti sa faci selectia in interogare?
Cred ca ar fi mai simplu, asta daca nu exista alte motive serioase sa faci cum vrei tu. |
--------------------
...
..
.. Americanii il vor pe Ciolos.. i-au dat si viza!
|
|
GeorgeB |
![]()
Post
#24
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
eu am un XML recursiv. am facut un XSL care citeste XML ul recursiv. acum am nevoie sa selectez elemente dupa id ul lor. de fapt dupa bucati din id ul lor. aici e pb mea. pentru a formata output ul imi trebuie sa pot face acest lucru si pentru a face aceasta trebuie sa selectez tot timpul elementul tata al frunzei pe care ma aflu . asta e tot.
|
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#25
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
in XPATH pentru a selecta atributul elementului parinte se foloseste :
CODE select="(parent::*/attribute::id)" acum , despre partea a doua , cum pot sa caut un element dupa o parte din id ul sau? |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#26
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
adica care ar fi wildcard ul pentru Xpath, pentru ca * nu functioneaza.
|
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
GeorgeB |
![]()
Post
#27
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
am reusit sa imi selectez anumite ITEM uri dupa id ul lor, de fapt dupa parti din id ul lor folosind functiile pentru string uri . cautam , taiem , numram
![]() idea este ca merge. nu la fel de frumos ca atunci cand as fi putut folosi wildcarduri (sau jokeri dc vreti) dar merge la fel de bine ![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
neumann |
![]()
Post
#28
|
![]() Membru autentic Group: Members Posts: 783 Joined: 6 November 03 From: Spermezeu ![]() |
|
--------------------
...
..
.. Americanii il vor pe Ciolos.. i-au dat si viza!
|
|
GeorgeB |
![]()
Post
#29
|
![]() the 7 stars of Pleiades constellation Group: Members Posts: 1.870 Joined: 7 January 03 From: Bucuresti ![]() |
in SQL stiu si io ..
![]() problema este in Xpath ![]() ![]() |
--------------------
SUBARU
Legacy 2.5
- --- L7 2.5 all in black - edition -
|
|
neumann |
![]()
Post
#30
|
![]() Membru autentic Group: Members Posts: 783 Joined: 6 November 03 From: Spermezeu ![]() |
Am presupus ca ai datele intr-un sql server si folosesti clauza "for XML" dupa care afisezi cu ajutorul xsl.
Pe de alta parte, daca lucrezi procedural, atunci tre' sa cauti o functie de genul strcmp(), nu cred sa ai wildcard-uri. Adica compari stringuri, ceea ce se pare ca ai facut deja ![]() This post has been edited by cristianco2002: 14 Dec 2004, 18:23 |
--------------------
...
..
.. Americanii il vor pe Ciolos.. i-au dat si viza!
|
|
![]() ![]() ![]() |
Lo-Fi Version Harta site Parteneri Jocuri online Curs Valutar HRH Haine din lana merinos | Time is now: 24th July 2025 - 01:19 |