xsl-list
[Top] [All Lists]

[xsl] Posting to XSL-List - Good Subject Lines

2017-06-28 22:47:20
When replying the list digest please replace the automagically create subject 
line, which is the digest, with the name of the thread to which you are 
responding. Good subject lines make the discussion available in the archives. 

It is interesting that in 2017 we see significantly more traffic to the 
XSL-List archive than the list. I take this to mean that many people find some 
of the answers they are looking for in the archive and don’t feel the need to 
ask the list. 

Thank you for using good subject lines in XSL-List, and for copying the subject 
line of the message to which you are responding into the subject line if you 
are responding to the list digest. 

— Tommie



On Jun 28, 2017, at 11:26 PM, Terry Badger terry_badger(_at_)yahoo(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Think this is a key problem so try something like this.            
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheetxmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:xs="http://www.w3.org/2001/XMLSchema"exclude-result-prefixes="xs"version="2.0";>
<xsl:keyname="Document_Name__c"match="Data__c" use="Document_Name__c"/>
<xsl:output method="xml"indent="yes"/>
<xsl:param name="XMLMerge2"select="document('merge2.xml')"/>
<xsl:template match="objects">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="Alert__c">
<xsl:if test="key('Document_Name__c', Document_Name__c, $XMLMerge2)">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>


Terry Badger
badger-software.com


On Wednesday, June 28, 2017 5:07 AM, "Rahul Singh 
rahulsinghindia15(_at_)gmail(_dot_)com" 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:



Thanks 


On Wed, Jun 21, 2017 at 2:50 PM, XSL-List: The Open Forum on XSL 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

This message contains the recent posts to the XSL-List: The Open Forum on XSL
mailing list managed by Mulberry Technologies, Inc. 
(http://lists.mulberrytech.com ).



---------- Forwarded message ----------
From: Rahul Singh <rahulsinghindia15(_at_)gmail(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: 
Bcc: 
Date: Tue, 20 Jun 2017 18:59:40 +0530
Subject: XSL Condition is not working

My xsl code is not working as per given expected output. I need data from 
merge1.xml if Alert_Type__c='Document Downloaded' and 
Document_Name__c='abcTest.txt' is match with merge2.xml with 
Document_Name__c='abcTest.txt' and Alert_Type__c!='Document Downloaded'


Input
Merge1.xml: 


   <?xml version="1.0" encoding="UTF-8"?>
   <objects>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>b (2).txt</Document_Name__c>
   </Alert__c>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>w.txt</ Document_Name__c>
    </Alert__c>
    <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>w.txt</ Document_Name__c>
   </Alert__c>
   <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>file 1.pdf</Document_Name__c>
   </Alert__c>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>abcTest. txt</Document_Name__c>
   </Alert__c>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>VICS_810_ 004010_US.pdf</Document_Name__ c>
   </Alert__c>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>VICS_810_ 004010_US.pdf</Document_Name__ c>
    </Alert__c>
    </objects>


Merge2.xml:


  <?xml version="1.0" encoding="UTF-8"?>
  <objects>
  <Data__c>
  <Document_Name__c>abcTest.txt< /Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
  <Data__c>
  <Document_Name__c>w.txt</ Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
  </Data__c>
  <Data__c>
  <Document_Name__c>q.txt</ Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
  <Document_Name__c>file 1.pdf</Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
  </Data__c>
  <Data__c>
  <Document_Name__c> DealRoomData.csv</Document_ Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
  <Data__c>
  <Document_Name__c>b (2).txt</Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
  </Data__c>
  <Data__c>
  <Document_Name__c>w.txt</ Document_Name__c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
  </Data__c>
  <Data__c>
  <Document_Name__c>VICS_810_ 004010_US.pdf</Document_Name__ c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
  </Data__c>
  <Data__c>
  <Document_Name__c>VICS_810_ 004010_US.pdf</Document_Name__ c>
  <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
  </objects>


XSL:


  <?xml version="1.0" encoding="UTF-8"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/ 1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/ 2001/XMLSchema" exclude-result-prefixes="xs" 
version="2.0">
  <xsl:output method="xml" indent="yes"/>
  <xsl:param name="XMLMerge2" select="document('merge2.xml') "/>
  <xsl:template match="objects">
      <objects>
          <xsl:if test="
                  $XMLMerge2/objects != ''">
              <xsl:for-each select="Alert__c">
                  <xsl:variable name="Email_from_merge1" 
select="Alert_Type__c"/>
                  <xsl:variable name="Email_from_merge2" 
select="Document_Name__c"/>
                  <xsl:if
                      test="not(exists($XMLMerge2/ 
objects/Data__c[Alert_Type__c = $Email_from_merge1]))">
                      <xsl:if
                          test="exists($XMLMerge2/ 
objects/Data__c[Document_Name_ _c = $Email_from_merge2])">
                          <xsl:copy>
                              <xsl:apply-templates select="@* | node()"/>
                          </xsl:copy>
                      </xsl:if>
                  </xsl:if>
              </xsl:for-each>
          </xsl:if>
      </objects>
    </xsl:template>
    <xsl:template match="@* | node()">
      <xsl:copy>
          <xsl:apply-templates select="@* | node()"/>
      </xsl:copy>
   </xsl:template>
  </xsl:stylesheet>


Expected  output:


   <?xml version="1.0" encoding="UTF-8"?>
   <objects>
  <Alert__c>
  <Alert_Type__c>Document Downloaded</Alert_Type__c>
  <Document_Name__c>abcTest.txt< /Document_Name__c>
   </Alert__c>
  </objects>

---------- Forwarded message ----------
From: Priscilla Walmsley <pwalmsley(_at_)datypic(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Cc: 
Bcc: 
Date: Tue, 20 Jun 2017 13:22:52 -0400
Subject: XSLT at the XML Summer School 2017

Hello,
We have announced the program for the XML Summer School, which takes 
placeSeptember 17-22in Oxford, UK.  
The XSLT and XQuery course may be of particular interest.  It is 
anintermediate to advanced course with the goal of helping developers who 
arecurrently using XSLT to be more effective and efficient.  It's a 
greatopportunity to spend some time with XSLT and XQuery experts like 
MichaelKay, Florent Georges and Adam Retter (and me!).  The classes are:
- XSLT and XQuery Performance Workshop (taught by Michael Kay)
- Refactoring XSLT (taught by Priscilla Walmsley)
- Querying XML Databases with XQuery (taught by Adam Retter)
- XSLT 3.0 and XQuery 3.0 (taught by Florent Georges)
There is also quite a lot of XSLT in the Hands-onDigitalPublishing course 
forslightly less experienced XSLT developers. Taught by Norm Walsh, 
PeterFlynn, Lauren Wood and Matt Patterson, the classes teach practical 
methodsfor transforming both XML and Word documents to HTML5 for Web and 
ePub publishing.
Of course, the rest of the curriculum and faculty are excellent also. Youcan 
find out more at:
http://xmlsummerschool.com/ curriculum-2017/
Consider travelling to the beautiful town of Oxford this summer to 
furtheradvance your XSLT skills and socialize with people with the same 
interestsand challenges in a relaxed setting. 
Please feel free to contact me if you have any question about the 
curriculumor the Summer School in general.  Hope to see you there!
Priscilla

---------- Forwarded message ----------
From: "Imsieke, Gerrit, le-tex" <gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: 
Bcc: 
Date: Tue, 20 Jun 2017 20:03:22 +0200
Subject: Re: [xsl] XSL Condition is not working
I don’t understand it fully. The output comprises all of merge1.xml’s 
Alter__c  items because all meet your conditions.

Why do you expect that the output objects element contains only 
Alert__c[Document_Name__c = 'abcTest.txt']]?

For example, take
<Alert__c>
<Alert_Type__c>Document Downloaded</Alert_Type__c>
<Document_Name__c>w.txt</Docum ent_Name__c>
</Alert__c>

$Email_from_merge1 is 'Document Downloaded'

not(exists($XMLMerge2/objects/ Data__c[Alert_Type__c = $Email_from_merge1])) 
is true
because all Data__c in merge2.xml have an Alert_Type__c of 'Document Viewed'

$Email_from_merge2 is 'w.txt'
$XMLMerge2/objects/Data__c[Doc ument_Name__c = 'w.txt'] exists (there are 
two Data__c with Document_Name__c = 'w.txt').

So for this example both 'if' conditions are true, and for all other 
Alert__c elements, too.

This explains the output, yet it doesn’t explain why it is different from 
your expectations.

Gerrit

On 6/20/17 3:30 PM, Rahul Singh rahulsinghindia15(_at_)gmail(_dot_)com wrote:

My xsl code is not working as per given expected output. I need data from 
merge1.xml if Alert_Type__c='Document Downloaded' and 
Document_Name__c='abcTest.txt' is match with merge2.xml with 
Document_Name__c='abcTest.txt' and Alert_Type__c!='Document Downloaded'

Input
Merge1.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <objects>
    <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>b (2).txt</Document_Name__c>
    </Alert__c>
    <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
     <Document_Name__c>w.txt</Docu ment_Name__c>
     </Alert__c>
     <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>w.txt</Docum ent_Name__c>
    </Alert__c>
    <Alert__c>
     <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>file 1.pdf</Document_Name__c>
    </Alert__c>
    <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>abcTest.txt< /Document_Name__c>
    </Alert__c>
    <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
     <Document_Name__c>VICS_810_00 4010_US.pdf</Document_Name__c>
    </Alert__c>
    <Alert__c>
    <Alert_Type__c>Document Downloaded</Alert_Type__c>
    <Document_Name__c>VICS_810_004 010_US.pdf</Document_Name__c>
     </Alert__c>
     </objects>

Merge2.xml:

   <?xml version="1.0" encoding="UTF-8"?>
   <objects>
   <Data__c>
   <Document_Name__c>abcTest. txt</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
    </Data__c>
   <Data__c>
   <Document_Name__c>w.txt</Docu ment_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
   <Document_Name__c>q.txt</Docu ment_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
    </Data__c>
    <Data__c>
   <Document_Name__c>file 1.pdf</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
   <Document_Name__c>DealRoomDat a.csv</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
    </Data__c>
   <Data__c>
   <Document_Name__c>b (2).txt</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
   <Document_Name__c>w.txt</Docu ment_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
   <Document_Name__c>VICS_810_00 4010_US.pdf</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
   </Data__c>
   <Data__c>
   <Document_Name__c>VICS_810_00 4010_US.pdf</Document_Name__c>
   <Alert_Type__c>Document Viewed</Alert_Type__c>
    </Data__c>
   </objects>

XSL:

   <?xml version="1.0" encoding="UTF-8"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1 999/XSL/Transform"
   xmlns:xs="http://www.w3.org/2 001/XMLSchema" 
exclude-result-prefixes="xs" version="2.0">
   <xsl:output method="xml" indent="yes"/>
   <xsl:param name="XMLMerge2" select="document('merge2.xml') "/>
   <xsl:template match="objects">
       <objects>
           <xsl:if test="
                   $XMLMerge2/objects != ''">
               <xsl:for-each select="Alert__c">
                   <xsl:variable name="Email_from_merge1" 
select="Alert_Type__c"/>
                   <xsl:variable name="Email_from_merge2" 
select="Document_Name__c"/>
                   <xsl:if
                       test="not(exists($XMLMerge2/o 
bjects/Data__c[Alert_Type__c = $Email_from_merge1]))">
                       <xsl:if
                           test="exists($XMLMerge2/objec 
ts/Data__c[Document_Name__c = $Email_from_merge2])">
                           <xsl:copy>
                               <xsl:apply-templates select="@* | node()"/>
                           </xsl:copy>
                       </xsl:if>
                   </xsl:if>
               </xsl:for-each>
           </xsl:if>
       </objects>
     </xsl:template>
     <xsl:template match="@* | node()">
       <xsl:copy>
           <xsl:apply-templates select="@* | node()"/>
       </xsl:copy>
    </xsl:template>
   </xsl:stylesheet>

Expected  output:

    <?xml version="1.0" encoding="UTF-8"?>
    <objects>
   <Alert__c>
   <Alert_Type__c>Document Downloaded</Alert_Type__c>
   <Document_Name__c>abcTest. txt</Document_Name__c>
    </Alert__c>
   </objects>
XSL-List info and archive <http://www.mulberrytech.com/x sl/xsl-list>
EasyUnsubscribe <http://lists.mulberrytech.com /unsub/xsl-list/225679> (by 
email <mailto:ulberrytech.com?subject=remove >)

-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler



XSL-List info and archive 
EasyUnsubscribe (by email) 


====================================================================== 
B. Tommie Usdin                        
mailto:btusdin(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com    
17 West Jefferson Street                           Phone: 301/315-9631 
Suite 207                                    Direct Line: 301/315-9634 
Rockville, MD  20850                                 Fax: 301/315-8285 
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in XML and SGML               
======================================================================
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>