Jump to content

Scrier

Members
  • Posts

    35
  • Joined

  • Last visited

Scrier's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. I managed to make it validate with the following complextype: <xs:complexType name="paramtype" mixed="true"> <xs:attribute name="type" type="xs:string" use="required" /> <xs:attribute name="arraySize" type="xs:string" /> <xs:attribute name="length" type="xs:string" /> </xs:complexType> Problem here is that I cannot validate the element now.
  2. I have the following XML file that I have issues with validating a specific part of. <params> <param @type="int">intType</param> <param @type="char" length="5">tagString</param></params> I try the following schema to identify it but have issues with mixing attribute and restrictions. <!-- Complextype matching the "param". --> <xs:complexType name="paramtype"> <xs:restriction base="xs:string"> <xs:pattern value="[a-z]+([A-Z][a-z]*)*" /> </xs:restriction> <xs:attribute name="type" type="xs:string" use="required" /> <xs:attribute name="arraySize" type="xs:string" /> <xs:attribute name="length" type="xs:string" /> </xs:complexType> <!-- Complextype matching the "params". --> <xs:complexType name="paramstype"> <xs:sequence> <xs:element name="param" maxOccurs="unbounded" type="paramtype"/> </xs:sequence> </xs:complexType> It complains on the following part: I have tried some combinations before and after the restriction part but still don't get it to work. I have tried the examples but all the examples on wc3 as well as the book I have is either element or attribute, not combined.
  3. Im looking to do a match template that I can loop up in until I find a specific node. The template I have atm looks like this: <xsl:template match="if|and|case|condition|sequence" mode="repetition"> <xsl:choose> <xsl:when test="sequence"> <!-- Do something else, we found the node --> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="parent::*" mode="repetition" /> </xsl:otherwise> </xsl:choose></xsl:template> And as you probably understand the xml is nested if, and, case, condition parameters that i need to go up through to find the overlying sequence, here is an example of the tree: <sequence> <something /></sequence><validation> <case> <if> <and /> <and /> </if> </case></validation> so I can be in any underlying node on if, and etc and need to find up to the sequence nodeThe current template complains that I try to loop around ".", although I have tried parent::node() and some others but all seems to think I loop around the same element and not the overlying.
  4. I found out how to manage this with some trial and error. <!-- find each namespace element --><xsl:template match="element" mode="sourceMandatoryElement"> <xsl:choose> <xsl:when test="@namespace = 4014"> <xsl:apply-templates select="./element" mode="sourceMandatoryElement" /> <xsl:apply-templates select="." mode="sourceMandatoryElementIf" /> </xsl:when> <xsl:when test="@namespace = 4045"> </xsl:when> </xsl:choose></xsl:template><!-- handle if cases --><xsl:template match="element" mode="sourceMandatoryElementIf"> <xsl:variable name="testcase" select="' '" /> <xsl:for-each select="./element"> <xsl:choose> <xsl:when test="position() = 1 and position() = last()"> <xsl:text>if( </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet() )</xsl:text> </xsl:when> <xsl:when test="position() = 1"> <xsl:text>if( </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet()</xsl:text> </xsl:when> <xsl:when test="position() = last()"> <xsl:text> || </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet() )</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> || </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet()</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text>{</xsl:text> <xsl:choose> <xsl:when test="@classname = 001"> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_001::PRESENT);</xsl:text> <xsl:text>}</xsl:text> <xsl:text>else</xsl:text> <xsl:text>{</xsl:text> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_001::NOT_PRESENT);</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_002::PRESENT);</xsl:text> <xsl:text>}</xsl:text> <xsl:text>else</xsl:text> <xsl:text>{</xsl:text> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_002::NOT_PRESENT);</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text></xsl:template> What it does is that you check a state for all underlying elements and depending if its true or false we set a value of the overlying element.
  5. Hello.I'm currently trying to make c++ code from xsl / xslt and making if cases from subelements and have made it to a certain extent so far but i'm currently stuck at one part.The xml is built up in the following way: <element namespace="4014" classname="002" id="_3"> <element namespace="4004" classname="012" id="_3_1" /></element><element namespace="4014" classname="001" id="_4"> <element namespace="281" classname="431" id="_4_1" /> <element namespace="282" classname="431" id="_4_2" /> <element namespace="4130" classname="007" id="_4_3" /></element><element namespace="4014" classname="001" id="_5"> <element namespace="4014" classname="002" id="_5_1"> <element namespace="4028" classname="001" id="_5_1_1" /> </element> <element namespace="4014" classname="002" id="_5_2"> <element namespace="365" classname="401" id="_5_2_1" /> </element> <element namespace="4014" classname="002" id="_5_3"> <element namespace="4028" classname="005" id="_5_3_1" /> </element> <element namespace="4014" classname="002" id="_5_4"> <element namespace="4037" classname="002" id="_5_4_1" /> </element></element> and the xsl is in the following manner: <!-- loop through all elements and Delete this function --><xsl:template match="sequence" mode="sourceMandatory"> <xsl:for-each select="element"> <xsl:apply-templates select="." mode="sourceMandatoryElement" /> </xsl:for-each></xsl:template><!-- find each namespace element --><xsl:template match="element" mode="sourceMandatoryElement"> <xsl:choose> <xsl:when test="@namespace = 4014"> <xsl:apply-templates select="." mode="sourceMandatoryElementIf" /> </xsl:when> <xsl:when test="@namespace = 4045"> </xsl:when> </xsl:choose></xsl:template><!-- handle if cases --><xsl:template match="element" mode="sourceMandatoryElementIf"> <xsl:variable name="testcase" select="' '" /> <xsl:for-each select="./element"> <xsl:choose> <xsl:when test="@namespace = 4014"> <xsl:apply-templates select="." mode="sourceMandatoryElementIf" /> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="position() = 1 and position() = last()"> <xsl:text>if( </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet() )</xsl:text> </xsl:when> <xsl:when test="position() = 1"> <xsl:text>if( </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet()</xsl:text> </xsl:when> <xsl:when test="position() = last()"> <xsl:text> || </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet() )</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text> || </xsl:text><xsl:value-of select="@id" /><xsl:text>->isValueSet()</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:text>{</xsl:text> <xsl:choose> <xsl:when test="@classname = 001"> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_001::PRESENT);</xsl:text> <xsl:text>}</xsl:text> <xsl:text>else</xsl:text> <xsl:text>{</xsl:text> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_001::NOT_PRESENT);</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_002::PRESENT);</xsl:text> <xsl:text>}</xsl:text> <xsl:text>else</xsl:text> <xsl:text>{</xsl:text> <xsl:value-of select="@id" /><xsl:text>->setValue(namespace_4014::classname_002::NOT_PRESENT);</xsl:text> </xsl:otherwise> </xsl:choose> <xsl:text>}</xsl:text></xsl:template> And the output looks fine, i.e: if( _3_1->isValueSet() ){_3->setValue(DFI_4014::DUI_002::PRESENT);}else{_3->setValue(DFI_4014::DUI_002::NOT_PRESENT);}if( _4_1->isValueSet() || _4_2->isValueSet() || _4_3->isValueSet() ){_4->setValue(DFI_4014::DUI_001::PRESENT);}else{_4->setValue(DFI_4014::DUI_001::NOT_PRESENT);}if( _5_1_1->isValueSet() ){_5_1->setValue(DFI_4014::DUI_002::PRESENT);}else{_5_1->setValue(DFI_4014::DUI_002::NOT_PRESENT);} But then when I try to get the following code if( _5_1->isValueSet() || _5_2->isValueSet() || _5_3->isValueSet() || _5_4->isValueSet() ){_5->setValue(DFI_4014::DUI_002::PRESENT);}else{_5->setValue(DFI_4014::DUI_002::NOT_PRESENT);} i.e the ones with elements under elements I have some issues, saving in a variable or adding it in a new template call won't work, Kinda stuck on this as it seems it wont save in xsl:when templates. Any help appreciated and ask if clarification is needed as im not sure what i want to achieve is clarified as good as I wan't to.
  6. Hi, Is it possible to decrease or increase the value of a number represented in an xml file with xsl? i.e I have the field <number>##</number>What I wan't to do is to get the string value of the above or below number value representation with xsl. I.e if the number was 15 I would like to get 14 or 16. // Andreas
  7. Thank you for that, it helped me to sort it out, apparently I was on message level so had to change to ./extrainclude instead of the whole search.
  8. Hi, I have the following xsl if case in a template called createHeader: <xsl:if test="messages/message/extrainclude">#include "<xsl:value-of select="messages/message/extrainclude"/>"</xsl:if> Problem is if I actually add the tag on this level it won't be added when I generate it.i.e
  9. Thanks alot. Will have to look into that one a bit more.
  10. Hi, I have a xml dokument with a couple of spans. in the following order: <span> <from>0</from> <to>23</to></span><span> <from>31</from> <to>31</to></span> And the issue I have with a call-template is how to make this into a proper if statement. If I only have one I can use this call <xsl:template match="span" mode="ifvalue"> <xsl:value-of select="from" /> <= value && value <= <xsl:value-of select="to" /></xsl:template> and it comes out as if( 0 <= value && value <= 23 ) Problem is if I have more than one span I wan't it to come out as: if( 0 <= value && value <= 23 || 31 <= value && value <= 31 ) or if( 0 <= value && value <= 23 || 31 == value ) But I can't really find a way to know if it is more than 1 span and how to put it in before the second so I don't get it in the end.Any help is appreciated// Scrier
  11. Thanks alot for the help and idd it was way easier just to parse the data instead >_< some things is to easy to think of I guess
  12. Well I have some problems adding php code to be executed inside a news post. The newsposting looks like this: echo " </div> <div style=\"text-align: justify; padding-top: 1px;\"> ".$news['content']." </div> </fieldset> "; Works well and all and I can use html tags inside it to format the news. example : Netherspite<A HREF=/images/Kills/Karazhan/netherspite.jpg TARGET="_blank"><IMG SRC=/images/Kills/Karazhan/netherspite2.jpg WIDTH=600 BORDER=0></A> Now what I would like to do is to add in this news executable php code.. More exactly the following thing should "echo" out: echo itemstats_parse("[item]Rip-Flayer Leggings[/item]"); (that is how to execute it in php but to make it work inside the newspost I am not really sure. Have tried some various things but I seems to do something wrong.) itemstats_parse("[item]Rip-Flayer Leggings[/item]");"itemstats_parse("[item]Rip-Flayer Leggings[/item]")"".itemstats_parse("[item]Rip-Flayer Leggings[/item]")."<? echo itemstats_parse("[item]Rip-Flayer Leggings[/item]"); ?>"<? echo itemstats_parse("[item]Rip-Flayer Leggings[/item]"); ?>" in the newspost adds the following results: itemstats_parse("[item]Rip-Flayer Leggings[/item]");"itemstats_parse("[item]Rip-Flayer Leggings[/item]")"".itemstats_parse("[item]Rip-Flayer Leggings[/item]").""" Just ask me if you need anymore feedback I think im just doing some silly mistake somewhere, but just can't figure it out where.
  13. Tried stripping away all "unceccecary" things (prolly stripped something I shouldn't) and got this: <html><body> <a onmouseover="return escape('will be 30 minutes late or so.');"><img src="images/note.gif" border="0"></a><script language="JavaScript" type="text/javascript" src="wz_tooltip.js"></script></body></html> Now this works on the old site but not the new site. explain this to me please old sitenew site
  14. Can post the generated code from the writeouts if it helps.This is the old site: <tr valign=top> <td bgcolor=#FFFFFF> <a onmouseover="return escape('<div class=\'wowitem wowitemlive\'><span class=\'iname\'><span class=\'purplename\'>Handwraps of Flowing Thought</span></span><br />Binds when picked up<br />Hands<span class=\'wowrttxt\'>Cloth</span><br />106 Armor<br />+19 Stamina<br />+19 Intellect<br /><img class=\'esock\' src=\'/images/yellowsocket.png\' alt=\'yellow\' /> Yellow Socket<br /><img class=\'esock\' src=\'/images/bluesocket.png\' alt=\'blue\' /> Blue Socket<br /><span class=\'greyname\'>Socket Bonus: +3 Spell Hit Rating</span><br />Requires Level 70<br /><span class=\'itemeffectlink\'>Equip: <a href=\'http://wow.allakhazam.com/db/spell.html?wspell=17367\' class=\'itemeffectlink\'>Increases damage and healing done by magical spells and effects by up to 32.</a> </span><br /><span class=\'itemeffectlink\'>Equip: Improves spell hit rating by 12.</span><br /><br/><span class=\'akznotice\'> </span></div>')" href=item.php?itemid=848&type=99>Handwraps of Flowing Thought</a> </td></tr> And the new site: <tr valign=top> <td bgcolor=#FFFFFF> <a onmouseover="return escape('<div class=\'wowitem wowitemlive\'><span class=\'iname\'><span class=\'purplename\'>Handwraps of Flowing Thought</span></span><br />Binds when picked up<br />Hands<span class=\'wowrttxt\'>Cloth</span><br />106 Armor<br />+19 Stamina<br />+19 Intellect<br /><img class=\'esock\' src=\'/images/yellowsocket.png\' alt=\'yellow\' /> Yellow Socket<br /><img class=\'esock\' src=\'/images/bluesocket.png\' alt=\'blue\' /> Blue Socket<br /><span class=\'greyname\'>Socket Bonus: +3 Spell Hit Rating</span><br />Requires Level 70<br /><span class=\'itemeffectlink\'>Equip: <a href=\'http://wow.allakhazam.com/db/spell.html?wspell=17367\' class=\'itemeffectlink\'>Increases damage and healing done by magical spells and effects by up to 32.</a> </span><br /><span class=\'itemeffectlink\'>Equip: Improves spell hit rating by 12.</span><br /><br/><span class=\'akznotice\'> </span></div>')" href=item.php?itemid=2&type=40>Handwraps of Flowing Thought</a> </td></tr> I can't find anything diffing them tbh but saving the files as htm I get various results on the new site but it works to put up the old site as htm and run it. So the return escape function works but for some reason the generated code (which is identical imo) won't work.
  15. Well I've moved a site to a new host that is supposedly more stable than the last one we had, Although on the new site a return escape function has stopped working, think it's part of a wz_tooltip and I'm wondering why. I am guessing that some setting or something on the host is not up to date for some reason. The following example: <a onmouseover="return escape('This is a test')"><h1>ITEMS</h1></a><br> Does not give a mouseover at all and i'm wondering if anyone knows what might be wrong. Any help appreciated. (Note the code works on the old host but not the new)
×
×
  • Create New...