Search Results

Search found 1542 results on 62 pages for 'xsl xpath'.

Page 2/62 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Reusing XSL template to be invoked with different relative XPaths

    - by meomaxy
    Here is my contrived example that illustrates what I am attempting to accomplish. I have an input XML file that I wish to flatten for further processing. Input file: <BICYCLES> <BICYCLE> <COLOR>BLUE</COLOR> <WHEELS> <WHEEL> <WHEEL_TYPE>FRONT</WHEEL_TYPE> <FLAT>NO</FLAT> <REFLECTORS> <REFLECTOR> <REFLECTOR_NUM>1</REFLECTOR_NUM> <COLOR>RED</COLOR> <SHAPE>SQUARE</SHAPE> </REFLECTOR> <REFLECTOR> <REFLECTOR_NUM>2</REFLECTOR_NUM> <COLOR>WHITE</COLOR> <SHAPE>ROUND</SHAPE> </REFLECTOR> </REFLECTORS> </WHEEL> <WHEEL> <WHEEL_TYPE>REAR</WHEEL_TYPE> <FLAT>NO</FLAT> </WHEEL> </WHEELS> </BICYCLE> </BICYCLES> The input is a list of <BICYCLE> nodes. Each <BICYCLE> has a <COLOR> and optionally has <WHEELS>. <WHEELS> is a list of <WHEEL> nodes, each of which has a few attributes, and optionally has <REFLECTORS>. <REFLECTORS> is a list of <REFLECTOR> nodes, each of which has a few attributes. The goal is to flatten this XML. This is the XSL I'm using: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" xml:space="preserve"/> <xsl:template match="/"> <BICYCLES> <xsl:apply-templates/> </BICYCLES> </xsl:template> <xsl:template match="BICYCLE"> <xsl:choose> <xsl:when test="WHEELS"> <xsl:apply-templates select="WHEELS"/> </xsl:when> <xsl:otherwise> <BICYCLE> <COLOR><xsl:value-of select="COLOR"/></COLOR> <WHEEL_TYPE/> <FLAT/> <REFLECTOR_NUM/> <COLOR/> <SHAPE/> </BICYCLE> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="WHEELS"> <xsl:apply-templates select="WHEEL"/> </xsl:template> <xsl:template match="WHEEL"> <xsl:choose> <xsl:when test="REFLECTORS"> <xsl:apply-templates select="REFLECTORS"/> </xsl:when> <xsl:otherwise> <BICYCLE> <COLOR><xsl:value-of select="../../COLOR"/></COLOR> <WHEEL_TYPE><xsl:value-of select="WHEEL_TYPE"/></WHEEL_TYPE> <FLAT><xsl:value-of select="FLAT"/></FLAT> <REFLECTOR_NUM/> <COLOR/> <SHAPE/> </BICYCLE> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="REFLECTORS"> <xsl:apply-templates select="REFLECTOR"/> </xsl:template> <xsl:template match="REFLECTOR"> <BICYCLE> <COLOR><xsl:value-of select="../../../../COLOR"/></COLOR> <WHEEL_TYPE><xsl:value-of select="../../WHEEL_TYPE"/></WHEEL_TYPE> <FLAT><xsl:value-of select="../../FLAT"/></FLAT> <REFLECTOR_NUM><xsl:value-of select="REFLECTOR_NUM"/></REFLECTOR_NUM> <COLOR><xsl:value-of select="COLOR"/></COLOR> <SHAPE><xsl:value-of select="SHAPE"/></SHAPE> </BICYCLE> </xsl:template> </xsl:stylesheet> The output is: <BICYCLES xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <BICYCLE> <COLOR>BLUE</COLOR> <WHEEL_TYPE>FRONT</WHEEL_TYPE> <FLAT>NO</FLAT> <REFLECTOR_NUM>1</REFLECTOR_NUM> <COLOR>RED</COLOR> <SHAPE>SQUARE</SHAPE> </BICYCLE> <BICYCLE> <COLOR>BLUE</COLOR> <WHEEL_TYPE>FRONT</WHEEL_TYPE> <FLAT>NO</FLAT> <REFLECTOR_NUM>2</REFLECTOR_NUM> <COLOR>WHITE</COLOR> <SHAPE>ROUND</SHAPE> </BICYCLE> <BICYCLE> <COLOR>BLUE</COLOR> <WHEEL_TYPE>REAR</WHEEL_TYPE> <FLAT>NO</FLAT> <REFLECTOR_NUM/> <COLOR/> <SHAPE/> </BICYCLE> </BICYCLES> What I don't like about this is that I'm outputting the color attribute in several forms: <COLOR><xsl:value-of select="../../../../COLOR"/></COLOR> <COLOR><xsl:value-of select="../../COLOR"/></COLOR> <COLOR><xsl:value-of select="COLOR"/></COLOR> <COLOR/> It seems like there ought to be a way to make a named template and invoke it from the various places where it is needed and pass some parameter that represents the path back to the <BICYCLE> node to which it refers. Is there a way to clean this up, say with a named template for bicycle fields, for wheel fields and for reflector fields? In the real world example this is based on, there are many more attributes to a "bicycle" than just color, and I want to make this XSL easy to change to include or exclude fields without having to change the XSL in multiple places.

    Read the article

  • Cannot add namespace prefix to children using XSL

    - by Erdal
    I checked many answers here and I think I am almost there. One thing that is bugging me (and for some reason my peer needs it) follows: I have the following input XML: <?xml version="1.0" encoding="utf-8"?> <MyRoot> <MyRequest CompletionCode="0" CustomerID="9999999999"/> <List TotalList="1"> <Order CustomerID="999999999" OrderNo="0000000001" Status="Shipped"> <BillToAddress ZipCode="22221"/> <ShipToAddress ZipCode="22222"/> <Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </Order> </List> <Errors/> </MyRoot> I was asked to produce this: <ns:MyNewRoot xmlns:ns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <N1:MyRequest CompletionCode="0" CustomerID="9999999999"/> <ns:List TotalList="1"> <N2:Order CustomerID="999999999" Level="Preferred" Status="Shipped"> <N2:BillToAddress ZipCode="22221"/> <N2:ShipToAddress ZipCode="22222"/> <N2:Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </N2:Order> </ns:List> <ns:Errors/> </ns:MyNewRoot> Note the children of the N2:Order also needs N2: prefix as well as the ns: prefix for the rest of the elements. I use the XSL transformation below: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="/MyRoot"> <MyNewRoot xmlns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <xsl:apply-templates/> </MyNewRoot> </xsl:template> <xsl:template match="/MyRoot/MyRequest"> <xsl:element name="N1:{name()}" namespace="http://schemas.foo.com/request"> <xsl:copy-of select="namespace::*"/> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> <xsl:template match="/MyRoot/List/Order"> <xsl:element name="N2:{name()}" namespace="http://schemas.foo.com/details"> <xsl:copy-of select="namespace::*"/> <xsl:apply-templates select="@* | node()"/> </xsl:element> </xsl:template> </xsl:stylesheet> This one doesn't process the ns (I couldn't figure this out). When I process thru the above the XSL transformation with AltovaXML I end up with below: <MyNewRoot xmlns="http://schemas.foo.com/response" xmlns:N1="http://schemas.foo.com/request" xmlns:N2="http://schemas.foo.com/details"> <N1:MyRequest CompletionCode="0" CustomerID="9999999999"/> <List xmlns="" TotalList="1"> <N2:Order CustomerID="999999999" Level="Preferred" Status="Shipped"> <BillToAddress ZipCode="22221"/> <ShipToAddress ZipCode="22222"/> <Totals Tax="0.50" SubTotal="10.00" Shipping="4.95"/> </N2:Order> </List> <Errors/> </MyNewRoot> Note that N2: prefix for the children of Order is not there after the XSL transformation. Also additional xmlns="" in the Order header (for some reason). I couldn't figure out putting the ns: prefix for the rest of the elements (like Errors and List). First of all, why would I need to put the prefix for the children if the parent already has it. Doesn't the parent namespace dictate the children nodes/attribute namespaces? Secondly, I want to add the prefixes in the above XML as expected, how can I do that with XSL?

    Read the article

  • XMl to XHTML using XSL with namespace

    - by user256007
    How to handle XML Elements with namespace in an XSL. Here goes my XML Document <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xml" href="wpanel.xsl" ?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:bong="http://bong/glob/wpanel" xml:lang="en" lang="en"> <head> <title> Transitional DTD XHTML Example </title> <link rel="stylesheet" type="text/css" href="wpanel.css" /> </head> <body> <bong:QButton text="Submit"></bong:QButton> <bong:QButton text="Reset"></bong:QButton> </body> </html> and My XSL goes here <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:bong="http://bong/glob/wpanel" xmlns:fn="http://www.w3.org/2005/xpath-functions" > <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" /> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> <xsl:template match="processing-instruction()|comment()"> <xsl:copy>.</xsl:copy> </xsl:template> I want to copy the elements without bong namespace as it is But transform those using the bong namespace. I think there will be an xsl element or attribute for that.I've serched the net. but haven't found yet. Thank You.

    Read the article

  • Improving the performance of XSL

    - by Rachel
    In the below XSL for the variable "insert-data", I have an input param with the structure, <insert-data> <data compareIndex="4" nodeName="d1e1"> <a/> </data> <data compareIndex="5" nodeName="d1e1"> <b/> </data> <data compareIndex="7" nodeName="d1e2"> <a/> </data> <data compareIndex="9" nodeName="d1e2"> <b/> </data> </insert-data> where "nodeName" is the id of a node and "compareIndex" is the position of the text content relative to the node having id "$nodeName". I am using the below XSL to select all the text nodes(generate-id) that satisfy the above condition and construct a data xml. The below implementation works perfectly but the time taken for the execution is in min. Is there a better way of implementing or is there any in-efficient operation being used. From my observation the code where the preceding text length is calculated consumes the major time. Please share your thoughts to improve the performance of the XSL. I am using Java SAXON XSL transformer. <xsl:variable name="insert-data" as="element()*"> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:sort select="xsd:integer(@index)"/> <xsl:variable name="compareIndex" select="xsd:integer(@compareIndex)" /> <xsl:variable name="nodeName" select="@nodeName" /> <xsl:variable name="nodeContent" as="node()"> <xsl:copy-of select="node()"/> </xsl:variable> <xsl:for-each select="$main-root/*//text()[ancestor::*[@id = $nodeName]]"> <xsl:variable name="preTextLength" as="xsd:integer" select="sum((preceding::text())[. ancestor::*[@id = $nodeName]]/string-length(.))" /> <xsl:variable name="currentTextLength" as="xsd:integer" select="string-length(.)" /> <xsl:variable name="sum" select="$preTextLength + $currentTextLength" as="xsd:integer"></xsl:variable> <xsl:variable name="split-index" select="$compareIndex - $preTextLength" as="xsd:integer"></xsl:variable> <xsl:if test="($sum ge $compareIndex) and ($compareIndex gt $preTextLength)"> <data split-index="{$split-index}" text-id="{generate-id(.)}"> <xsl:copy-of select="$nodeContent"/> </data> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:variable>

    Read the article

  • Set attribute to all child elements via xsl:choose

    - by Camal
    Hi, assuming I got following XML file : <?xml version="1.0" encoding="ISO-8859-1" ?> <MyCarShop> <Car gender="Boy"> <Door>Lamborghini</Door> <Key>Skull</Key> </Car> <Car gender="Girl"> <Door>Normal</Door> <Key>Princess</Key> </Car> </MyCarShop> I want to perform a transformation so the xml looks like this : <?xml version="1.0" encoding="ISO-8859-1" ?> <MyCarShop> <Car gender="Boy"> <Door color="blue">Lamborghini</Door> <Key color="blue">Skull</Key> </Car> <Car gender="Girl"> <Door color="red">Normal</Door> <Key color="red">Princess</Key> </Car> </MyCarShop> So I want to add a color attribut to each subelement of Car depending on the gender information. I came up with this XSLT but it doesnt work : <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" > <xsl:output method="xml" indent="yes"/> <!--<xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template>--> <xsl:template match="/"> <xsl:element name="MyCarShop"> <xsl:attribute name="version">1.0</xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="Car"> <xsl:element name="Car"> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="Door"> <xsl:element name="Door"> <xsl:attribute name="ViewSideIndicator"> <xsl:choose> <xsl:when test="gender = 'Boy' ">Front</xsl:when> <xsl:when test="gender = 'Girl ">Front</xsl:when> </xsl:choose> </xsl:attribute> </xsl:element> </xsl:template> <xsl:template match="Key"> <xsl:element name="Key"> <xsl:apply-templates/> </xsl:element> </xsl:template> </xsl:stylesheet> Does anybody know what might be wrong ? Thanks again!

    Read the article

  • Xpath and parameters

    - by Daniel
    I am relatively new to XSL and I think this is a basic question. So I better get my apologies in early! Basically, I would like to use a value-of function. This will be in a template and I would like to pass part of the xpath as a parameter. <xsl:variable name="TEST_VAR">"h:elementA/elementB"</xsl:variable> ... and then use the variable (or passed in param) as all (or part) of the xpath: <xsl:element name="transformedElement"><xsl:value-of select=$TEST_VAR/></xsl:element> I would really like to have the xpath to be a mixture of string literals and the vlue of TEST_VAR. Thanks in advance

    Read the article

  • Problem sorting RSS feed by date using XSL

    - by Buckers
    I'm creating a website where I need to show the top 5 records from an RSS feed, and these need to be sorted by date and time. The date fields in the RSS feed are in the following format: "Mon, 16 Feb 2009 16:02:44 GMT" I'm having big problems getting the records to sort correctly - I've tried lots of different code examples I've seen, but none seem to sort the records correctly. The code for my XSL sheet is shown below, and the feed in question is here. Very grateful for anyones help!!! Thanks, Chris. XSL CODE: <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:digg="http://digg.com//docs/diggrss/" xmlns:dc="http://purl.org/dc/elements/1.1/"> <xsl:template match="/"> <xsl:for-each select="//*[local-name()='item'][position() < 6]"> <p> <a> <xsl:attribute name="href"> <xsl:value-of select="*[local-name()='link']"/></xsl:attribute> <xsl:attribute name="target"> <xsl:text>top</xsl:text> </xsl:attribute> <xsl:value-of select="*[local-name()='title']"/> </a> <br/> <span class="smaller"><xsl:value-of select="*[local-name()='pubDate']" disable-output-escaping="yes"/></span> </p> </xsl:for-each>

    Read the article

  • Making an XSL stylesheet work with paged XML

    - by fudgey
    First off, here is the situation. I'm using a guild hosting site that allows you to input the URL to an XSL file and another input for the XML. All well and good when all of the XML you want is contained in one file. My problem is this Game Roster XML which is paginated... look near the bottom of the file and you will find a <page_links> section that contains a pager written in HTML with links to /xml?page=2 etc. Since the guild hosting site is set up to only process one XML page I can't get to the other XML pages. So, I can only think of two solutions, but I have no idea how to get started Set up a php page that combines all XML pages into one, then output that file. I can then use this URL in the guild hosting site XSL processor. Somehow combine all the XML files within the XSL stylesheet. I found this question on SO (I don't really understand it, because I don't know what the document($pXml1) is doing), but I don't think it will work since the number of pages will be variable. I think this might be possible by loading the next page until the <members_to> value equals the <members_total>. Any other ideas? I don't know XSL or php that well so any help with code examples would be greatly appreciated. Update: I'm trying method 2 above and here is a snippet of XSLT with which I am having trouble. The first page of the code displays without problems, but the I am having trouble with this xsl:if, or maybe it's the document() statement. Update #2: changed the document to use the string & concat functions, but it's still not working. <xsl:template name="morepages"> <xsl:param name="page">1</xsl:param> <xsl:param name="url"> <xsl:value-of select="concat(SuperGroup/profule_url,'/xml?page=')"/> </xsl:param> <xsl:if test="document(string(concat($url,$page)))/SuperGroup/members_to &lt; document(string(concat($url,$page)))/SuperGroup/members_total"> <xsl:for-each select="document(string(concat($url,$page + 1)))/SuperGroup/members/members_node"> <xsl:call-template name="addrow" /> </xsl:for-each> <!-- Increment page index--> <xsl:call-template name="morepages"> <xsl:with-param name="page" select="$page + 1"/> </xsl:call-template> </xsl:if> </xsl:template>

    Read the article

  • Usage of Document() function in XSLT 1.0

    - by infant programmer
    I am triggering the transformation using a .NET code, unless I add "EnableDocumentFunction" property to the XSL-Setting, the program throws error saying .. "Usage of Document() function is prohibited", Actually the program is not editable and a kind of read-only .. is it possible to edit the XSL code itself so that I can use document() function?? The sample XSL and XMLs are Here: Sample XML : <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl" > <xsl:output method="xml" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:variable name="State_Code_Trn"> <State In="California" Out="CA"/> <State In="CA" Out="CA"/> <State In="Texas" Out="TX"/> <State In="TX" Out="TX"/> </xsl:variable> <xsl:template name="testing" match="test_node"> <xsl:variable name="test_val"> <xsl:value-of select="."/> </xsl:variable> <xsl:element name="{name()}"> <xsl:choose> <xsl:when test="document('')/*/xsl:variable[@name='State_Code_Trn'] /State[@In=$test_val]"> <xsl:value-of select="document('')/*/xsl:variable[@name='State_Code_Trn'] /State[@In=$test_val]/@Out"/> </xsl:when> <xsl:otherwise> <xsl:text>Other</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:element> </xsl:template> </xsl:stylesheet> And the sample XML : <?xml version="1.0" encoding="utf-8"?> <root> <test_node>California</test_node> <test_node>CA</test_node> <test_node> CA</test_node> <test_node>Texas</test_node> <test_node>TX</test_node> <test_node>CAA</test_node> <test_node></test_node> </root>

    Read the article

  • xsl:include template with no default namespace causes xmlns=""

    - by CraftyFella
    Hi, I've got a problem with xsl:include and default namespaces which is causing the final xml document contain nodes with the xmlns="" In this synario I have 1 source document which is Plain Old XML and doesn't have a namespace: <?xml version="1.0" encoding="UTF-8"?> <SourceDoc> <Description>Hello I'm the source description</Description> <Description>Hello I'm the source description 2</Description> <Description/> <Title>Hello I'm the title</Title> </SourceDoc> This document is transformed into 2 different xml documents each with their own default namespace. First Document: <?xml version="1.0" encoding="utf-8"?> <OutputDocType1 xmlns="http://MadeupNS1"> <Description >Hello I'm the source description</Description> <Description>Hello I'm the source description 2</Description> <Title>Hello I'm the title</Title> </OutputDocType1> Second Document: <?xml version="1.0" encoding="utf-8"?> <OutputDocType2 xmlns="http://MadeupNS2"> <Description>Hello I'm the source description</Description> <Description>Hello I'm the source description 2</Description> <DocTitle>Hello I'm the title</DocTitle> </OutputDocType2> I want to be able to re-use the template for descriptions in both of the transforms. As it's the same logic for both types of document. To do this I created a template file which was *xsl:include*d in the other 2 transformations: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml"/> <xsl:template match="Description[. != '']"> <Description> <xsl:value-of select="."/> </Description> </xsl:template> </xsl:stylesheet> Now the problem here is that this shared transformation can't have a default Namespace as it will be different depending on which of the calling transformations calls it. E.g. for First Document Transformation: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="xml"/> <xsl:template match="SourceDoc"> <OutputDocType1 xmlns="http://MadeupNS1"> <xsl:apply-templates select="Description"/> <xsl:if test="Title"> <Title> <xsl:value-of select="Title"/> </Title> </xsl:if> </OutputDocType1> </xsl:template> <xsl:include href="Template.xsl"/> </xsl:stylesheet> This actually outputs it as follows: <?xml version="1.0" encoding="utf-8"?> <OutputDocType1 xmlns="http://MadeupNS1"> <Description xmlns="">Hello I'm the source description</Description> <Description xmlns="">Hello I'm the source description 2</Description> <Title>Hello I'm the title</Title> </OutputDocType1> Here is the problem. On the description Lines I get an xmlns="" Does anyone know how to solve this issue? Thanks Dave

    Read the article

  • XSL unique values per node per position

    - by Nathan Colin
    this get ever more complicated :) now i face another issue in last question we managed to take unique values from only one parent node now with: <?xml version="1.0" encoding="ISO-8859-1"?> <roots> <root> <name>first</name> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>C</something> <something>P</something> </item> <item> <something>A</something> <something>L</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>D</something> <something>A</something> </item> </root> <root> <name>second</name> <item> <something>E</something> <something>A</something> </item> <item> <something>B</something> <something>A</something> </item> <item> <something>F</something> <something>A</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>A</something> <something>A</something> </item> <item> <something>B</something> <something>H</something> </item> <item> <something>D</something> <something>G</something> </item> </root> </roots> now i need to get the unique values depending only from one node before but just from the elements on the second position <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes" method="text"/> <xsl:key name="item-by-value" match="something" use="concat(normalize-space(.), ' ', generate-id(./ancestor::root))"/> <xsl:key name="rootkey" match="root" use="name"/> <xsl:template match="/"> <xsl:for-each select="key('rootkey','first')"> <xsl:for-each select="item/something[1]"> <xsl:sort /> <xsl:if test="generate-id() = generate-id(key('item-by-value', concat(normalize-space(.), ' ', generate-id(./ancestor::root))))"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> <xsl:text>_________</xsl:text> <xsl:for-each select="item/something[2]"> <xsl:sort /> <xsl:if test="generate-id() = generate-id(key('item-by-value', concat(normalize-space(.), ' ', generate-id(./ancestor::root))))"> <xsl:value-of select="."/> </xsl:if> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> with this XSL i get ABCD__LP where the result i need is ABCD__ALP any ideas?

    Read the article

  • XSL ignores my whitespace even with the <xsl:text> tag

    - by danielle
    I'm making a header in my XSL code that includes multiple fields of information, i.e. "Name: Bob Birthdate: January 1 1900," etc. I enclosed them in tags as such: <xsl:text> Gender: Male </xsl:text> But on the page, the whitespace around Gender/Male is being ignored. Is there something I'm missing? Thanks in advance.

    Read the article

  • convert xml document to comma delimited (CSV) file using xslt stylesheet.

    - by Brad H
    I need some assistance converting an xml document to a CSV file using an xslt stylesheet. I am trying to use the following xsl and I can't seem to get it right. I want my comma delimited file to include column headings, followed by the data. My biggest issues are removing the final comma after the last item and inserting a carriage return so each group of data appears on a separate line. I have been using XML Notepad. <xsl:template match="/"> <xsl:element name="table"> <xsl:apply-templates select="/*/*[1]" mode="header" /> <xsl:apply-templates select="/*/*" mode="row" /> </xsl:element> </xsl:template> <xsl:template match="*" mode="header"> <xsl:element name="tr"> <xsl:apply-templates select="./*" mode="column" /> </xsl:element> </xsl:template> <xsl:template match="*" mode="row"> <xsl:element name="tr"> <xsl:apply-templates select="./*" mode="node" /> </xsl:element> </xsl:template> <xsl:template match="*" mode="column"> <xsl:element name="th"> <xsl:value-of select="translate(name(.),'qwertyuiopasdfghjklzxcvbnm_','QWERTYUIOPASDFGHJKLZXCVBNM ')" /> </xsl:element>, </xsl:template> <xsl:template match="*" mode="node"> <xsl:element name="td"> <xsl:value-of select="." /> </xsl:element>, </xsl:template>

    Read the article

  • BizTalk Testing Series - The xpath Function

    - by Michael Stephenson
    Background While the xpath function in a BizTalk orchestration is a very powerful feature I have often come across the situation where someone has hard coded an xpath expression in an orchestration. If you have read some of my previous posts about testing I've tried to get across the general theme like test-driven or test-assisted development approaches where the underlying principle is that your building up your solution of small well tested units that are put together and the resulting solution is usually quite robust. You will be finding more bugs within your unit tests and fewer outside of your team. The thing I don't like about the xpath functions usual usage is when you come across an orchestration which has something like the below snippet in an expression or assign shape: string result = xpath(myMessage,"string(//Order/OrderItem/ProductName)"); My main issue with this is that the xpath statement is hard coded in the orchestration and you don't really know it works until you are running the orchestration. Some of the problems I think you end up with are: You waste time with lengthy debugging of the orchestration when your statement isn't working You might not know the function isn't working quite as expected because the testable unit around it is big You are much more open to regression issues if your schema changes     Approach to Testing The technique I usually follow is to hold the xpath statement as a constant in a helper class or to format a constant with a helper function to get the actual xpath statement. It is then used by the orchestration like follows. string result = xpath(myMessage, MyHelperClass.ProductNameXPathStatement); This means that because the xpath statement is available outside of the orchestration it now becomes testable in its own right. This means: I can test it in its own right I'm less likely to waste time tracking down problems caused by an error in the statement I can reduce the risk or regression issuess I'm now able to implement some testing around my xpath statements which usually are something like the following:    The test will use a sample xml file The sample will be validated against the schema The test will execute the xpath statement and then check the results are as expected     Walk-through BizTalk uses the XPathNavigator internally behind the xpath function to implement the queries you will usually use using the navigators select or evaluate functions. In the sample (link at bottom) I have a small solution which contains a schema from which I have generated a sample instance. I will then use this instance as the basis for my tests.     In the below diagram you can see the helper class which I've encapsulated my xpath expressions in, and some helper functions which will format the expression in the case of a repeating node which would want to inject an index into the xpath query.             I have then created a test class which has some functions to execute some queries against my sample xml file. An example of this is below.         In the test class I have a couple of helper functions which will execute the xpath expressions in a similar way to BizTalk. You could have a proper helper class to do this if you wanted.         You can see now in the BizTalk expression editor I can use these functions alongside the xpath function.         Conclusion I hope you can see with very little effort you can make your life much easier by testing xpath statements outside of an orchestration rather than using them directly hard coded into the orchestration.     This can also save you lots of pain longer term because your build should break if your schema changes unexpectedly causing these xpath tests to fail where as your tests around the orchestration will be more difficult to troubleshoot and workout the cause of the problem.     Sample Link The sample is available from the following link: http://code.msdn.microsoft.com/testbtsxpathfunction     Other Tools On the subject of using the xpath function, if you don't already use it the below tool is very useful for creating your xpath statements (thanks BizBert) http://www.bizbert.com/bizbert/2007/11/30/XPath+The+Hidden+Language+Of+BizTalk.aspx

    Read the article

  • Why is it that, table is not printing in the xsl-fo here? please help me guys.

    - by atrueguy
    This is my xml file <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="currency.xsl"?> <currencylist> <title>Currencies By Country</title> <countries> <country>Australia</country> <currency>Australian Dollar</currency> </countries> <countries> <country>Austria</country> <currency>Schilling</currency> </countries> <countries> <country>Belgium</country> <currency>Belgium Franc</currency> </countries> <countries> <country>Canada</country> <currency>Canadian Dollar</currency> </countries> <countries> <country>England</country> <currency>Pound</currency> </countries> <countries> <country>Fiji</country> <currency>Fijian Dollar</currency> </countries> <countries> <country>France</country> <currency>Franc</currency> </countries> <countries> <country>Germany</country> <currency>DMark</currency> </countries> <countries> <country>Hong Kong</country> <currency>Hong Kong Dollar</currency> </countries> <countries> <country>Italy</country> <currency>Lira</currency> </countries> <countries> <country>Japan</country> <currency>Yen</currency> </countries> <countries> <country>Netherlands</country> <currency>Guilder</currency> </countries> <countries> <country>Switzerland</country> <currency>SFranc</currency> </countries> <countries> <country>USA</country> <currency>Dollar</currency> </countries> </currencylist> This is my xsl-fo file: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="Letter" page-height="11in" page-width="8.5in"> <fo:region-body region-name="only_region" margin="0.7in" margin-top="1.2in" margin-left="1.1in"/> <fo:region-before region-name="xsl-region-before" extent="1.5in" /> <fo:region-after region-name="xsl-region-after" extent="1.5in" /> <fo:region-start region-name="xsl-region-after" extent="1.5in" /> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="Letter"> <fo:flow flow-name="only_region"> <fo:block text-align="left"><xsl:call-template name="show_title"/></fo:block> <fo:table-and-caption> <fo:table> <fo:table-column column-width="25mm"/> <fo:table-column column-width="25mm"/> <fo:table-column column-width="25mm"/> <fo:table-header> <fo:table-row> <fo:table-cell> <fo:block font-weight="bold">SI No</fo:block> </fo:table-cell> <fo:table-cell> <fo:block font-weight="bold">Country</fo:block> </fo:table-cell> <fo:table-cell> <fo:block font-weight="bold">Currency</fo:block> </fo:table-cell> </fo:table-row> </fo:table-header> <fo:table-body> <xsl:for-each select="currencylist/countries"> <fo:table-row> <fo:table-cell> <fo:block> <xsl:value-of select="position()"/> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block> <xsl:value-of select="country"/> </fo:block> </fo:table-cell> <fo:table-cell> <fo:block> <xsl:value-of select="currency"/> </fo:block> </fo:table-cell> </fo:table-row> </xsl:for-each> </fo:table-body> </fo:table> </fo:table-and-caption> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template name="show_title" match="currencylist"> <xsl:value-of select="currencylist/title"/> </xsl:template> </xsl:stylesheet> Table structure is not printing, but the values are printing, please help guys.

    Read the article

  • In xpath why can I use greater-than symbol > but not less-than <

    - by runrunraygun
    Using c#3 compiled transforms the following seems to work just fine... <xsl:choose> <xsl:when test="$valA > $valB"> <xsl:value-of select="$maxUnder" /> </xsl:when> <xsl:when test="$valA &lt; $valC"> <xsl:value-of select="$maxOver" /> </xsl:when> </xsl:choose> However if i dare use a < in place of &lt; it gives an error... <xsl:choose> <xsl:when test="$valA > $valB"> <xsl:value-of select="$maxUnder" /> </xsl:when> <xsl:when test="$valA < $valC"> <xsl:value-of select="$maxOver" /> </xsl:when> </xsl:choose> System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. So why is > ok and not < ?

    Read the article

  • Merge functionality of two xsl files into a single file (continued.....)

    - by anuamb
    This is in continuation of my question: Merge functionality of two xsl files into a single file (not a xsl import or include issue) I have to merge the solution (xsl) of above question to below xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <Declaration> <Message> <Meduim> <xsl:value-of select="/Declaration/Message/Meduim"/> </Meduim> <MessageIdentifier> <xsl:value-of select="/Declaration/Message/MessageIdentifier"/> </MessageIdentifier> <ControlingAgencyCode> <xsl:value-of select="/Declaration/Message/ControlingAgencyCode"/> </ControlingAgencyCode> <AssociationAssignedCode> <xsl:value-of select="/Declaration/Message/AssociationAssignedCode"/> </AssociationAssignedCode> <CommonAccessReference> <xsl:value-of select="/Declaration/Message/CommonAccessReference"/> </CommonAccessReference> </Message> <BeginingOfMessage> <MessageCode> <xsl:value-of select="/Declaration/BeginingOfMessage/MessageCode"/> </MessageCode> <DeclarationCurrency> <xsl:value-of select="/Declaration/BeginingOfMessage/DeclarationCurrency"/> </DeclarationCurrency> <MessageFunction> <xsl:value-of select="/Declaration/BeginingOfMessage/MessageFunction"/> </MessageFunction> </BeginingOfMessage> <Header> <ProcessingInformation> <xsl:for-each select="/Declaration/Header/ProcessingInformation/ProcessingInstructions"> <ProcessingInstructions> <xsl:value-of select="."/> </ProcessingInstructions> </xsl:for-each> </ProcessingInformation> <xsl:for-each select="/Declaration/Header/Seal"> <Seal> <SealID> <xsl:value-of select="SealID"/> </SealID> <SealLanguage> <xsl:value-of select="SealLanguage"/> </SealLanguage> </Seal> </xsl:for-each> <xsl:choose> <xsl:when test='/Declaration/Header/DeclarantsReference = ""'> <DeclarantsReference> <xsl:text disable-output-escaping="no">A</xsl:text> </DeclarantsReference> </xsl:when> <xsl:otherwise> <DeclarantsReference> <xsl:value-of select="/Declaration/Header/DeclarantsReference"/> </DeclarantsReference> </xsl:otherwise> </xsl:choose> <xsl:for-each select="/Declaration/Header/Items"> <Items> <CustomsStatusOfGoods> <CPC> <xsl:value-of select="CustomsStatusOfGoods/CPC"/> </CPC> <CommodityCode> <xsl:value-of select="CustomsStatusOfGoods/CommodityCode"/> </CommodityCode> <ECSuplementaryMeasureCode1> <xsl:value-of select="CustomsStatusOfGoods/ECSuplementaryMeasureCode1"/> </ECSuplementaryMeasureCode1> <ECSuplementaryMeasureCode2> <xsl:value-of select="CustomsStatusOfGoods/ECSuplementaryMeasureCode2"/> </ECSuplementaryMeasureCode2> <PreferenceCode> <xsl:value-of select="CustomsStatusOfGoods/PreferenceCode"/> </PreferenceCode> </CustomsStatusOfGoods> <xsl:for-each select="ItemAI"> <ItemAI> <AICode> <xsl:value-of select="AICode"/> </AICode> <AIStatement> <xsl:value-of select="AIStatement"/> </AIStatement> <AILanguage> <xsl:value-of select="AILanguage"/> </AILanguage> </ItemAI> </xsl:for-each> <Locations> <CountryOfOriginCode> <xsl:value-of select="Locations/CountryOfOriginCode"/> </CountryOfOriginCode> <xsl:for-each select="Locations/ItemCountryonRouteCode"> <ItemCountryonRouteCode> <xsl:value-of select="."/> </ItemCountryonRouteCode> </xsl:for-each> <ItemDispatchCountry> <xsl:value-of select="Locations/ItemDispatchCountry"/> </ItemDispatchCountry> <ItemDestinationCountry> <xsl:value-of select="Locations/ItemDestinationCountry"/> </ItemDestinationCountry> </Locations> <Measurements> <GrossMass> <xsl:value-of select="Measurements/GrossMass"/> </GrossMass> <NetMass> <xsl:value-of select="Measurements/NetMass"/> </NetMass> <SupplementaryUnits> <xsl:value-of select="Measurements/SupplementaryUnits"/> </SupplementaryUnits> <ThirdQuantity> <xsl:value-of select="Measurements/ThirdQuantity"/> </ThirdQuantity> </Measurements> <xsl:for-each select="Package"> <Package> <PackageNumber> <xsl:value-of select="PackageNumber"/> </PackageNumber> <PackageKind> <xsl:value-of select="PackageKind"/> </PackageKind> <PackageMarks> <xsl:value-of select="PackageMarks"/> </PackageMarks> <PackageLanguage> <xsl:value-of select="PackageLanguage"/> </PackageLanguage> </Package> </xsl:for-each> <PriceValue> <ItemStatisticalValue> <xsl:value-of select="PriceValue/ItemStatisticalValue"/> </ItemStatisticalValue> <ItemPrice> <xsl:value-of select="PriceValue/ItemPrice"/> </ItemPrice> </PriceValue> <ItemReferences> <xsl:for-each select="ItemReferences/ContainerID"> <ContainerID> <xsl:value-of select="."/> </ContainerID> </xsl:for-each> <QuotaNo> <xsl:value-of select="ItemReferences/QuotaNo"/> </QuotaNo> <UNDangerousGoodsCode> <xsl:value-of select="ItemReferences/UNDangerousGoodsCode"/> </UNDangerousGoodsCode> </ItemReferences> <GoodsDescription> <GoodsDescription> <xsl:value-of select="GoodsDescription/GoodsDescription"/> </GoodsDescription> <GoodsDescriptionLanguage> <xsl:value-of select="GoodsDescription/GoodsDescriptionLanguage"/> </GoodsDescriptionLanguage> </GoodsDescription> <Documents> <xsl:for-each select="Documents/PreviousDocument"> <PreviousDocument> <PreviousDocumentKind> <xsl:value-of select="PreviousDocumentKind"/> </PreviousDocumentKind> <PreviousDocumentIdentifier> <xsl:value-of select="PreviousDocumentIdentifier"/> </PreviousDocumentIdentifier> <PreviousDocumentType> <xsl:value-of select="PreviousDocumentType"/> </PreviousDocumentType> <PreviousDocumentLanguage> <xsl:value-of select="PreviousDocumentLanguage"/> </PreviousDocumentLanguage> </PreviousDocument> </xsl:for-each> <xsl:for-each select="Documents/ItemDocument"> <ItemDocument> <DocumentCode> <xsl:value-of select="DocumentCode"/> </DocumentCode> <DocumentPart> <xsl:value-of select="DocumentPart"/> </DocumentPart> <DocumentQuantity> <xsl:value-of select="DocumentQuantity"/> </DocumentQuantity> <DocumentReason> <xsl:value-of select="DocumentReason"/> </DocumentReason> <DocumentReference> <xsl:value-of select="DocumentReference"/> </DocumentReference> <DocumentStatus> <xsl:value-of select="DocumentStatus"/> </DocumentStatus> <DocumentLanguage> <xsl:value-of select="DocumentLanguage"/> </DocumentLanguage> </ItemDocument> </xsl:for-each> </Documents> <Valuation> <ValuationMethodCode> <xsl:value-of select="Valuation/ValuationMethodCode"/> </ValuationMethodCode> <ItemValuationAdjustmentCode> <xsl:value-of select="Valuation/ItemValuationAdjustmentCode"/> </ItemValuationAdjustmentCode> <ItemValuationAdjustmentPercentage> <xsl:value-of select="Valuation/ItemValuationAdjustmentPercentage"/> </ItemValuationAdjustmentPercentage> </Valuation> <ItemTransportChargeMOP> <xsl:value-of select="ItemTransportChargeMOP"/> </ItemTransportChargeMOP> <xsl:for-each select="ItemProcessingInstructions"> <ItemProcessingInstructions> <xsl:value-of select="."/> </ItemProcessingInstructions> </xsl:for-each> </Items> </xsl:for-each> <NumberOfPackages> <xsl:value-of select="/Declaration/Header/NumberOfPackages"/> </NumberOfPackages> </Header> </Declaration> </xsl:template> </xsl:stylesheet> so for source xml <Declaration> <Message> <Meduim>#+#</Meduim> <MessageIdentifier>AA</MessageIdentifier> <CommonAccessReference></CommonAccessReference> </Message> <BeginingOfMessage> <MessageCode>ISD</MessageCode> <DeclarationCurrency></DeclarationCurrency> <MessageFunction>5</MessageFunction> </BeginingOfMessage> </Declaration> the final output is <Declaration> <Message> <Meduim></Meduim> <MessageIdentifier>AA</MessageIdentifier> </Message> <BeginingOfMessage> <MessageCode>ISD</MessageCode> <MessageFunction>5</MessageFunction> </BeginingOfMessage> </Declaration>

    Read the article

  • Issue with XSL Criteria

    - by Rachel
    I am using the below piece of XSL to select the id of the text nodes whose content has a given index. This index value in input will be relative to a spcified node whose id value is known. The criteria to select the text node is, The text node content should contain a index say 'i' relative to node say 'n' whose id value i know. 'i' and 'id of n' is got as index and nodeName from the input param as seen in the xsl. Node 'd1e5' has the text content whose index ranges from 1 to 33. When i give an index value greater than 33 i want the below criteria to fail but it does not, [sum((preceding::text(), .)[normalize-space()][. >> //*[@id=$nodeName]]/string-length(.)) ge $index] Input xml: <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" id="d1e1"> <head id="d1e3"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title id="d1e5">Every document must have a title</title> </head> <body id="d1e9"> <h1 id="d1e11" align="center">Very Important Heading</h1> <p id="d1e13">Since this is just a sample, I won't put much text here.</p> </body> </html> XSL code used: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0"> <xsl:param name="insert-file" as="node()+"> <insert-data><data index="1" nodeName="d1e5"></data><data index="34" nodeName="d1e5"></data></insert-data> </xsl:param> <xsl:param name="nodeName" as="xsd:string" /> <xsl:variable name="main-root" as="document-node()" select="/"/> <xsl:variable name="insert-data" as="element(data)*"> <xsl:for-each select="$insert-file/insert-data/data"> <xsl:sort select="xsd:integer(@index)"/> <xsl:variable name="index" select="xsd:integer(@index)" /> <xsl:variable name="nodeName" select="@nodeName" /> <data text-id="{generate-id($main-root/descendant::text()[sum((preceding::text(), .)[normalize-space()][. >> //*[@id=$nodeName]]/string-length(.)) ge $index][1])}"> </data> </xsl:for-each> </xsl:variable> <xsl:template match="/"> <Output> <xsl:copy-of select="$insert-data" /> </Output> </xsl:template> </xsl:stylesheet> Actual output: <?xml version="1.0" encoding="UTF-8"?> <Output> <data text-id="d1t8"/> <data text-id="d1t14"/> </Output> Expected output: <?xml version="1.0" encoding="UTF-8"?> <Output> <data text-id="d1t8"/> </Output> This solution works fine if index lies between 1 and 33. Any index value greater that 33 causes incorrect text nodes to get selected. I could not understand why the text node 'd1t14' is getting selected. Please share your thoughts.

    Read the article

  • how to use nokogiri methods .xpath & .at_xpath

    - by Radek
    I'm learning how to use nokogiri and few questions came to me based on the code below require 'rubygems' require 'mechanize' post_agent = WWW::Mechanize.new post_page = post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708') puts "\nabsolute path with tbody gives nil" puts post_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div[2]').xpath('text()').to_s.strip.inspect puts "\n.at_xpath gives an empty string" puts post_page.parser.at_xpath("//div[@id='posts']/div/table/tr/td/div[2]").at_xpath('text()').to_s.strip.inspect puts "\ntwo lines solution with .at_xpath gives an empty string" rows = post_page.parser.xpath("//div[@id='posts']/div/table/tr/td/div[2]") puts rows[0].at_xpath('text()').to_s.strip.inspect puts puts "two lines working code" rows = post_page.parser.xpath("//div[@id='posts']/div/table/tr/td/div[2]") puts rows[0].xpath('text()').to_s.strip puts "\none line working code" puts post_page.parser.xpath("//div[@id='posts']/div/table/tr/td/div[2]")[0].xpath('text()').to_s.strip puts "\nanother one line code" puts post_page.parser.at_xpath("//div[@id='posts']/div/table/tr/td/div[2]").xpath('text()').to_s.strip puts "\none line code with full path" puts post_page.parser.xpath("/html/body/div/div/div/div/div/table/tr/td/div[2]")[0].xpath('text()').to_s.strip is it better to use // or / in xpath? @AnthonyWJones says that 'the use of an unprefixed //' is not so good idea I had to remove tbody from any working xpath otherwise I got 'nil' result. How is possible to remove an element from the xpath to get things work? do I have to use .xpath twice to extract data if not using full xpath? why I cannot make .at_xpath working to extract data? it works nicely here what is the difference?

    Read the article

  • Integration with Multiple Versions of BizTalk HL7 Accelerator Schemas

    - by Paul Petrov
    Microsoft BizTalk Accelerator for HL7 comes with multiple versions of the HL7 implementation. One of the typical integration tasks is to receive one format and transmit another. For example, system A works HL7 v2.4 messages, system B with v2.3, and system C with v2.2. The system A is exchanging messages with B and C. The logical solution is to create schemas in separate namespaces for each system and assign maps on send ports. Schematic diagram of the messaging solution is shown below:   Nothing is complex about that conceptually. On the implementation level things can get nasty though because of the elaborate nature of HL7 schemas and sheer amount of message types involved. If trying to implement maps directly in BizTalk Map Editor one would quickly get buried by thousands of links between subfields of HL7 segments. Since task is repetitive because HL7 segments are reused between message types it's natural to take advantage of such modular structure and reduce amount of work through reuse. Here's where it makes sense to switch from visual map editor to old plain XSLT. The implementation is done in three steps. First, create XSL templates to map from segments of one version to another. This can be done using BizTalk Map Editor subsequently copying and modifying generated XSL code to create one xsl:template per segment. Group all segments for format mapping in one XSL file (we call it SegmentTemplates.xsl). Here's how template for the PID segment (Patient Identification) would look like this: <xsl:template name="PID"> <PID_PatientIdentification> <xsl:if test="PID_PatientIdentification/PID_1_SetIdPatientId"> <PID_1_SetIdPid> <xsl:value-of select="PID_PatientIdentification/PID_1_SetIdPatientId/text()" /> </PID_1_SetIdPid> </xsl:if> <xsl:for-each select="PID_PatientIdentification/PID_2_PatientIdExternalId"> <PID_2_PatientId> <xsl:if test="CX_0_Id"> <CX_0_Id> <xsl:value-of select="CX_0_Id/text()" /> </CX_0_Id> </xsl:if> <xsl:if test="CX_1_CheckDigit"> <CX_1_CheckDigitSt> <xsl:value-of select="CX_1_CheckDigit/text()" /> </CX_1_CheckDigitSt> </xsl:if> <xsl:if test="CX_2_CodeIdentifyingTheCheckDigitSchemeEmployed"> <CX_2_CodeIdentifyingTheCheckDigitSchemeEmployed> <xsl:value-of select="CX_2_CodeIdentifyingTheCheckDigitSchemeEmployed/text()" /> </CX_2_CodeIdentifyingTheCheckDigitSchemeEmployed> . . . // skipped for brevity This is the most tedious and time consuming part. Templates can be created for only those segments that are used in message interchange. Once this is done the rest goes much easier. The next step is to create message type specific XSL that references (imports) segment templates XSL file. Inside this file simple call segment templates in appropriate places. For example, beginning of the mapping XSL for ADT_A01 message would look like this:   <xsl:import href="SegmentTemplates_23_to_24.xslt" />  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />   <xsl:template match="/">    <xsl:apply-templates select="s0:ADT_A01_23_GLO_DEF" />  </xsl:template>   <xsl:template match="s0:ADT_A01_23_GLO_DEF">    <ns0:ADT_A01_24_GLO_DEF>      <xsl:call-template name="EVN" />      <xsl:call-template name="PID" />      <xsl:for-each select="PD1_PatientDemographic">        <xsl:call-template name="PD1" />      </xsl:for-each>      <xsl:call-template name="PV1" />      <xsl:for-each select="PV2_PatientVisitAdditionalInformation">        <xsl:call-template name="PV2" />      </xsl:for-each> This code simply calls segment template directly for required singular elements and in for-each loop for optional/repeating elements. And lastly, create BizTalk map (btm) that references message type specific XSL. It is essentially empty map with Custom XSL Path set to appropriate XSL: In the end, you will end up with one segment templates file that is referenced by many message type specific XSL files which in turn used by BizTalk maps. Once all segment maps are created they are widely reusable and all the rest work is very simple and clean.

    Read the article

  • XSL Template - reducing replication

    - by Chris
    Hey Sorry about the extremely vague question title (any suggestions for improvements welcome) I have an XSL document that, currently, has lots of replication that I want to reduce. Here is the following XML snippet I am working with <Unit Status="alive"> I am currently using the following XSL to show images based on the status of the Unit <xsl:choose> <xsl:when test="@Status = 'alive'"> <img src="/web/resources/graphics/accept.png" /> </xsl:when> <xsl:when test="@Status = 'missingUnit'"> <img src="/web/resources/graphics/error.png" /> </xsl:when> <xsl:when test="@Status = 'missingNode'"> <img src="/web/resources/graphics/exclamation.png" /> </xsl:when> <xsl:when test="@Status = 'unexpectedUnit'"> <img src="/web/resources/graphics/exclamation_blue.png" /> </xsl:when> <xsl:otherwise> <!-- Should never get here --> <img src="/web/resources/graphics/delete.png" /> </xsl:otherwise> </xsl:choose> How do I put this code in a template or stylesheet that will allow me to stop copying / pasting this everywhere. Thanks

    Read the article

  • XSL transformation of SVG adds namespace attribute to new tag

    - by Steve
    I have a SVG file that I want to extend by adding onclick handlers to edges and nodes. I also want to add a script tag referring to a JavaScript. The problem is that the script tag gets an empty namespace attribute added to it. I haven't found any information regarding this that I understand. Why does XSLT add an empty namespace? XSL file: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <xsl:output method="xml" encoding="utf-8" /> <xsl:template match="/svg:svg"> <xsl:copy> <script type="text/ecmascript" xlink:href="base.js" /> <!-- this tag gets a namespace attr --> <xsl:apply-templates /> </xsl:copy> </xsl:template> <!-- Identity transform http://www.w3.org/TR/xslt#copying --> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <!-- Check groups and add functions --> <xsl:template match="svg:g"> <xsl:copy> <xsl:if test="@class = 'node'"> <xsl:attribute name="onclick">node_clicked()</xsl:attribute> </xsl:if> <xsl:if test="@class = 'edge'"> <xsl:attribute name="onclick">edge_clicked()</xsl:attribute> </xsl:if> <xsl:apply-templates select="@*|node()" /> </xsl:copy> </xsl:template> </xsl:stylesheet>

    Read the article

  • Gone With the Wind?

    - by antony.reynolds
    Where Have All the Composites Gone? I was just asked to help out with an interesting problem at a customer.  All their composites had disappeared from the EM console, none of them showed as loading in the log files and there was an ominous error message in the logs. Symptoms After a server restart the customer noticed that none of his composites were available, they didn’t show in the EM console and in the log files they saw this error message: SEVERE: WLSFabricKernelInitializer.getCompositeList Error during parsing and processing of deployed-composites.xml file This indicates some sort of problem when parsing the deployed-composites.xml file.  This is very bad because the deployed-composites.xml file is basically the table of contents that tells SOA Infrastructure what composites to load and where to find them in MDS.  If you can’t read this file you can’t load any composites and your SOA Server now has all the utility of a chocolate teapot. Verification We can look at the deployed-composites.xml file from MDS either by connecting JDeveloper to MDS, exporting the file using WLST or exporting the whole soa-infra MDS partition by using EM->SOA->soa-infra->Administration->MDS Configuration.  Exporting via EM is probably the easiest because it then prepares you to fix the problem later.  After exporting the partition to local storage on the SOA Server I then ran an XSLT transform across the file deployed-composites/deployed-composites.xml. <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/1999/xhtml">     <xsl:output indent="yes"/>     <xsl:template match="/">         <testResult>             <composite-series>                 <xsl:attribute name="elementCount"><xsl:value-of select="count(deployed-composites/composite-series)"/></xsl:attribute>                 <xsl:attribute name="nameAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series[@name])"/></xsl:attribute>                 <xsl:attribute name="defaultAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series[@default])"/></xsl:attribute>                 <composite-revision>                     <xsl:attribute name="elementCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision)"/></xsl:attribute>                     <xsl:attribute name="dnAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision[@dn])"/></xsl:attribute>                     <xsl:attribute name="stateAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision[@state])"/></xsl:attribute>                     <xsl:attribute name="modeAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision[@mode])"/></xsl:attribute>                     <xsl:attribute name="locationAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision[@location])"/></xsl:attribute>                     <composite>                         <xsl:attribute name="elementCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision/composite)"/></xsl:attribute>                         <xsl:attribute name="dnAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision/composite[@dn])"/></xsl:attribute>                         <xsl:attribute name="deployedTimeAttributeCount"><xsl:value-of select="count(deployed-composites/composite-series/composite-revision/composite[@deployedTime])"/></xsl:attribute>                     </composite>                 </composite-revision>                 <xsl:apply-templates select="deployed-composites/composite-series"/>             </composite-series>         </testResult>     </xsl:template>     <xsl:template match="composite-series">             <xsl:if test="not(@name) or not(@default) or composite-revision[not(@dn) or not(@state) or not(@mode) or not(@location)]">                 <ErrorNode>                     <xsl:attribute name="elementPos"><xsl:value-of select="position()"/></xsl:attribute>                     <xsl:copy-of select="."/>                 </ErrorNode>             </xsl:if>     </xsl:template> </xsl:stylesheet> The output from this is not pretty but it shows any <composite-series> tags that are missing expected attributes (name and default).  It also shows how many composites are in the file (111) and how many revisions of those composites (115). <?xml version="1.0" encoding="UTF-8"?> <testResult xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/1999/xhtml">    <composite-series elementCount="111" nameAttributeCount="110" defaultAttributeCount="110">       <composite-revision elementCount="115" dnAttributeCount="114" stateAttributeCount="115"                           modeAttributeCount="115"                           locationAttributeCount="114">          <composite elementCount="115" dnAttributeCount="114" deployedTimeAttributeCount="115"/>       </composite-revision>       <ErrorNode elementPos="82">          <composite-series xmlns="">             <composite-revision state="on" mode="active">                <composite deployedTime="2010-12-15T11:50:16.067+01:00"/>             </composite-revision>          </composite-series>       </ErrorNode>    </composite-series> </testResult> From this I could see that one of the <composite-series> elements (number 82 of 111) seemed to be corrupt. Having found the problem I now needed to fix it. Fixing the Problem The solution was really quite easy.  First for safeties sake I took a backup of the exported MDS partition.  I then edited the deployed-composites/deployed-composites.xml file to remove the offending <composite-series> tag. Finally I restarted the SOA domain and was rewarded by seeing that the deployed composites were now visible. Summary One possible cause of not being able to see deployed composites after a SOA 11g system restart is a corrupt deployed-composites.xml file.  Retrieving this file from MDS, repairing it, and replacing it back into MDS can solve the problem.  This still leaves the problem of how did this file become corrupt!

    Read the article

  • Dynamically generate XPath expression using XML data

    - by iHeartGreek
    Hi! I would like to dynamically create XPath expressions in an XSL determined by data in an XML file. (i.e. the XML data is "concatenated" to create an XPath expression). Example of XML data: AAA BBB CCC Example of how I would like the XPath expression to look like: //AAA | //BBB | //CCC And this dynamic generation needs to be done in an XSL file. I am fairly new to XSL (and family) and would appreciate some general direction on how to tackle this problem. Thanks!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >